Problem: Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex u is called a child of vertex v and vertex v is called a parent of vertex u if there exists a directed edge from v to u. A vertex is called a leaf if it doesn't have children and has a parent.

Let's call a rooted tree a spruce if its every non-leaf vertex has at least 3 leaf children. You are given a rooted tree, check whether it's a spruce.

The definition of a rooted tree can be found [here](https://goo.gl/1dqvzz).

Input

The first line contains one integer n — the number of vertices in the tree (3 ≤ n ≤ 1 000). Each of the next n - 1 lines contains one integer pi (1 ≤ i ≤ n - 1) — the index of the parent of the i + 1-th vertex (1 ≤ pi ≤ i).

Vertex 1 is the root. It's guaranteed that the root has at least 2 children.

Output

Print "Yes" if the tree is a spruce and "No" otherwise.

Examples

Input

4
1
1
1


Output

Yes


Input

7
1
1
1
2
2
2


Output

No


Input

8
1
1
1
1
3
3
3


Output

Yes

Note

The first example:

<image>

The second example:

<image>

It is not a spruce, because the non-leaf vertex 1 has only 2 leaf children.

The third example:

<image>

Solution (in JAVA):

Solution:
//Author: Mo Abjal, MJP Rohilkhand University Bareilly, UP, India 2018.
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////********************//////////////////////////////////////////////
/////////////////////////////////////////*     S0LUT10N     *//////////////////////////////////////////////
/////////////////////////////////////////********************//////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////
import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
public class Main{
	public static StringTokenizer token = new StringTokenizer("");
	public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static PrintWriter output = new PrintWriter(System.out);
	public static void main(String[] afzal) throws Exception {		
		int N = ni();
		ArrayList<Integer> list[] = new ArrayList[N];
		for(int i=0;i<N;i++){
			list[i] = new ArrayList();
		}
		for(int i=0;i<N-1;i++){
			int y = ni()-1;
			list[y].add(i+1);
		}
		for(int i=0;i<N;i++){
			if(list[i].size()>0){
				int ans = 0;
				for(Integer k : list[i]){
					if(list[k].size()==0) ans++;
				}
				if(ans<3){
					output.println("NO"); output.close(); break;
				}
			}
		}
		output.println("YES"); output.close();
	}
	public static long gcd(long a,long b){
		if(b==0) return a;
		else return gcd(b,a%b);
	}
	public static String pc(char c){
		return Character.toString(c);
	} 
	public static Integer pci(char c){
		return pi(Character.toString(c));
	}
	public static Integer pi(String str){
		return Integer.parseInt(str);
	}
	public static Long pl(String str){
		return Long.parseLong(str);
	}
	public static String ps(Integer N){
		return Integer.toString(N);
	}
	public static char[] pcc(String str){
		return str.toCharArray();
	}
	public static Integer ni() throws IOException{
		if(!token.hasMoreElements()){
			token = new StringTokenizer(br.readLine());
		}
		return Integer.parseInt(token.nextToken());
	}
	public static Long nl() throws IOException{
		if(!token.hasMoreElements()){
			token = new StringTokenizer(br.readLine());
		}
		return Long.parseLong(token.nextToken());
	}
	public static Double nd() throws IOException{
		if(!token.hasMoreElements()){
			token = new StringTokenizer(br.readLine());
		}
		return Double.parseDouble(token.nextToken());
	}
	public static String ns() throws IOException{
		if(!token.hasMoreElements()){
			token = new StringTokenizer(br.readLine());
		}
		return token.nextToken();
	}
	public static Integer[] ai(int N) throws IOException{
		Integer A[] = new Integer[N];
		token = new StringTokenizer(br.readLine());
		for(int i=0;i<A.length;i++){
			A[i] = pi(token.nextToken());
		}
		return A;
	}
	public static long[] al(int N) throws IOException{
		long A[] = new long[N];
		token = new StringTokenizer(br.readLine());
		for(int i=0;i<N;i++){
			A[i] = Long.parseLong(token.nextToken());
		}
		return A;
	}
	public static char[][] acc(int N,int M) throws IOException{
		char C[][] = new char[N][M];
		for(int i=0;i<N;i++){
			token = new StringTokenizer(br.readLine());
			String s = token.nextToken();
			for(int j=0;j<M;j++){
				C[i][j] = s.charAt(j);
			}
		}
		return C;
	}
	public static String[] as(int N) throws IOException{
		String S[] = new String[N];
		token = new StringTokenizer(br.readLine());
		for(int i=0;i<S.length;i++){
			S[i] = token.nextToken();
		}
		return S;
	}
	public static double ncr(int n, int r){
		if(n==r) return 1;
		else
		return (fact(n)/(fact(r)*fact(n-r)));
	}
	public static long fact(long N){
		long fact = 1;
		for(int i=1;i<=N;i++){
			fact = fact * i;
		}
		return fact;
	}
	public static BigInteger factB(int N){
		BigInteger b = new BigInteger("1");
		for(int i=1;i<=N;i++){
			b = b.multiply(BigInteger.valueOf(i));
		}
		return b;
	}
	public static long sod(long N){
		long sum = 0;
		while(N>0){
			long x = N%10;
			sum = sum + x;
			N = N/10;
		}
		return sum;
	}
	public static Integer cd(long N){
		int count=0;
		while(N>0){
			N = N/10; count++;
		}
		return count=0;
	}
}
class Pair implements Comparable{
	int a,b;
	public Pair(int a,int b){
		this.a = a;
		this.b = b;
	}
	public int compareTo(Object p){
		Pair pa = (Pair)p;
		//if(this.a==pa.a) return this.b - pa.b;
		return this.a - pa.a;
	} 
}class Pair3 implements Comparable{
	int a,b,c;
	public Pair3(int a,int b,int c){
		this.a = a;
		this.b = b;
		this.c = c;
	}
	public int compareTo(Object p){
		Pair pa = (Pair)p;
		//if(this.a==pa.a) return this.b - pa.b;
		return this.a - pa.a;
	} 
}
//Copyright Reserved - Mo Abjal.