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:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.management.Query;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;

import java.util.PriorityQueue;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;

public class Solution { 
 	static  int mod=1000000007;

	public static void main(String[] args) throws IOException, InterruptedException {
		PrintWriter out=new PrintWriter(System.out); 
		BufferedReader br=new  BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
	    //reviser complement 2
		//hexadecimal
	   //st=new StringTokenizer(br.readLine());
	  int n=parseInt(br.readLine());
	  LinkedList<Integer>[] list=new LinkedList[n+1];
	  for(int i = 0; i <= n;++i){
		  list[i]=new LinkedList();
	  }
	  int i;
	 for(i=2; i <= n;++i){
		 int v=parseInt(br.readLine());
		 list[v].add(i);
		 
	 }
	 
	 for(i=1; i <= n;++i){
		 int s=list[i].size();
		 if(s==0) continue;
		 else if(s== 1 || s == 2){
			 out.println("No");
			 break;
		 }else{
			 int count=0;
			 for(int k:list[i]){
				 if(list[k].size() == 0) ++count;
			 }
			 if(count < 3){
				 out.print("No");
				 break;
			 }
		 }
	 }
	 if(i > n) out.print("Yes");
		
	    		
		
		
		
		
		
		out.close();
		
	
	
	
	
	}
	
	static boolean nim_game(int n){
		int[] win_pos=new int[]{2, 3, 5, 4};
		if(n > 0){
			for(int x: win_pos){
				if(x == n) return true;
			}
			if(n == 1) return false;
			if(!nim_game(n - 5)|| !nim_game(n - 3)|| !nim_game(n - 2)) return true;
		}
		return false;
	}
	static int xor_range(int n){
		if(n == 0) return 0;
		int r= n% 4;
		if(r == 0) return n;
		if(r == 1) return 1;
		if(r == 2) return n+1;
		return 0;
	}
	static void sol(int[] arr, int index, int time, int k, HashMap<Integer, Integer> map, int sum){
		if( time == k+1){ 
				if(map.containsKey(sum)) map.put(sum, map.get(sum) + 1);
				else map.put(sum, 1);
		}
		
		if(time <= k){
			for(int i=index ; i  < arr.length; ++i){
				sol(arr, i + 1 , time + 1 , k, map, sum + arr[i]);
			}
		}
	}
	
	static int combinaison(double n, double k){//c(n, k)= (k+1)/(n-k)
		double res= 1;
		for(int i= 1; i<=k; ++i){
			res *= (n-i+1)/(i);
		}
		return (int)res;
	}
	static int countmin(int a, int b, int c){
		//Given a sequence of three binary sequences A, B and C of N bits. Count the minimum bits
		//required to flip in A and B such that XOR of A and B is equal to C
		int res= a ^ b ^ c;
		int count=0;
		while(res != 0){
			++count;
			res&=res - 1;
		}
		return count;
	}
	static int countval(int n){//Given a positive integer n, find count of positive integers i such that 0 <= i <= n and n+i = n^i
		int count=0;
		while(n != 0){
			if((n & 1) == 0) ++count;
		}
		return 1<<count;
	}
	static int firstright(int x){
		
		int y=1;
		int pos=1;
		while((x&y) == 0){
			pos++;
			y<<=1;
		}
		return pos;
	}
	
	static int atob(int a, int b){
		int c= a^b;
		int count=0;
		while(c != 0){
			c&=(c-1);
			++count;
		}
		return count;
	}
	  
	
	static int setBits(int x){
		int count=0;
		if(x == 0) return 0;
		while(x != 0){
			if(x % 2 == 1){
				--x;
				++count;
			}
			x/=2;
			
		}
		return count;
	}
	static boolean isPower4(long x){
			if((x & (x-1)) != 0) return false;
			int count=0;
			while(x != 1){
				x>>=1;
				++count;
			}
			
			if(count % 2 == 0) return true;
			return false;
	
	}
	
	
	
	static long addOne(long x){// add one using bit manipulation
	    long y = 1; 
		while((x & y) != 0){
			x ^= y;
			y<<=1;
		}
		
		return x ^ y;
	}
	
	static int compute_xor_range(int n){// compute xor from 1 to n
		int r= n % 4;
		if(r== 0) return n;
		else if(r== 1) return 1;
		else if(r== 2) return n+1;
		else return 0;
				
	}
	
	static long number_combinaisons(long n){//n cardinal of set 
		//fonction return number of combinaisons
		return (1 << n) ;
	}
	
	static boolean isPoweroftwo(long x){
		//check a number is power of two 
		//we use x & (x-1) to eliminate the first set bit
		
		return (x!=0 && (x & (x-1)) == 0)?true:false;
	}
	
	static long findxor(long[] Set,long n){// this function find xor of xor's of all subsets
		//n is length of set array
		if(n >1 ) return 0;
		else return Set[0];
	}
	// pour generer un nombre entier a partir de binaire int a=0b111;
	
	static long MSB(long n){// most significant bit
		while((n&(n-1)) != 0){
			n &= n-1;
		}
		return n;
	}
	
	static long LSB(long n){
	      if(n == 0) return 0;
	      return n-(n & (n-1));
	}
	
	
	 
	
		
}