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.*;
import java.util.*;
import java.lang.*;
public class Codechef {
	PrintWriter out;
    StringTokenizer st;
    BufferedReader br;
 	
 	class Pair implements Comparable<Pair>
	{
	    int f;
	    int s;
 
	    Pair(int t, int r) {
	       f = t;
	       s = r;
	    }
	    public int compareTo(Pair p)
	    {
	    	if(this.f!=p.f)
	    		return this.f-p.f;
 
	    	return this.s-p.s;
	    }
 	}
 // 	class Sort implements Comparator<String> 
	// { 
	//     public int compare(String a, String b) 
	//     { 
	//     	return (a+b).compareTo(b+a);
	//     } 
	// }
 
	String ns() {
        while (st == null || !st.hasMoreElements()) {
 
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
 
    String nextLine() throws Exception {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            throw new Exception(e.toString());
        }
        return str;
    }
 
    int nextInt() {
        return Integer.parseInt(ns());
    }
 
    long nextLong() {
        return Long.parseLong(ns());
    }
 
    double nextDouble() {
        return Double.parseDouble(ns());
    }
	
	int upperBound(ArrayList<Integer> a,int key)
	{
		int l=0,r=a.size()-1;
		int i=0;

		while(l<=r)
		{
			int mid=(l+r)/2;

			if(a.get(mid)<=key)	l=mid+1;

			else{
				i=mid;
				r=mid-1;
			}
		}
		return a.get(i);
	}

	long power(long x,long y)
	{
	    long ans=1;
	    
	    while(y!=0)
	    {
	        if(y%2==1) ans=(ans*x)%mod;
	        x=(x*x)%mod;
	        y/=2;
	    }
	    return ans%mod;
	}

	long mod= 1000000007;

	void solve() throws IOException{
		int n=nextInt();
		int k=2;

		ArrayList a[] = new ArrayList[3001];
		for(int i=0;i<3001;i++)
			a[i]=new ArrayList<Integer>();

		for(int i=0;i<n-1;i++)
		{
			int m=nextInt();
			a[m].add(k++);
		}

		// for(int i=0;i<10;i++)
		// {
		// 	out.println(a[i]);
		// }

		ArrayDeque<Integer> q = new ArrayDeque<>();
		q.add(1);
		boolean ok=true;
		while(!q.isEmpty())
		{
			int m=q.poll();
			int cnt=0;
			ArrayList<Integer> list=a[m];
			for(int i : list)
			{
				if(a[i].size()==0)
					cnt++;
				
				else
					q.add(i);
			}
			if(cnt<3){
				ok=false;
				break;	
			}
		}
		if(ok)
			out.println("Yes");
		else
			out.println("No");




	}
  
    void run() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
		solve();
		out.flush();

		out.close();
	}
 
	public static void main(String args[]) throws IOException {
		new Codechef().run();
	}
  
}