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:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * @author Rohini Chandra
 */
import java.util.*;
import java.io.*;
public class rough{
    public static void main(String args[]) throws IOException{
       /*BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       PrintWriter pw = new PrintWriter(System.out);*/
       //List<Integer> list = new ArrayList<>();
       //Map<Integer,Integer> map = new HashMap<>();
       //Set<Integer> set = new HashSet<>();
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt(),c=0;
       List<Integer> list = new ArrayList<>(Collections.nCopies(n+1, 0));
       List<Integer> nc = new ArrayList<>(Collections.nCopies(n+1, 0));
       for(int i=2; i<=n; i++){
           list.set(i,sc.nextInt());
           nc.set(list.get(i), nc.get(list.get(i))+1);
       }
       boolean bool = true;
       for(int i=1; i<=n; i++){
           if(nc.get(i)!=0){
               c=0;
               for(int j=2; j<=n; j++){
                   if(list.get(j)==i && nc.get(j)==0)
                      c++; 
               }
               //prt(c);
               if(c<3){
                  bool = false;
                  break;
               }
           }
       }
       //prtl(list);prtl(nc);
       System.out.println(bool==false?"NO":"YES");
    }
                                        //******** PRINT ********//
    static void prt(int a){
       System.out.print(a);
    }
                                       //******** PRINTLN ********//
    static void prtl(List<Integer> b){
       System.out.println(b); 
    }         
                                       //******** FACTORIAL ********//
    static int fact(int n){
       if(n==1)
          return 1;
       else
          return n*fact(n-1);
    }
                                       //******** OCCURRENCE ********//
    static Map<String,Integer> ocr(String str[]){
           Map<String,Integer> map = new HashMap<>();
           for(int i=0; i<str.length; i++){
           if(!map.containsKey(str[i]))
              map.put(str[i], 1);
           else
              map.put(str[i], map.get(str[i])+1);
           }
           return map;
    }
                                        //******** PRIME OR NOT ********//
    static boolean isprime(long num){
        if(num<=1)
            return false;
        else if(num<=3)
            return true;
        else if(num%2==0 || num%3==0)
            return false;
        else{
            for(int i=5; i*i<=num; i+=6){
                if(num%i==0 || num%(i+2)==0)
                   return false; 
            }
            return true;
        }
    }
                                       //******** GCD ************//
    static long gcd(long a, long b){
         if(b==0)
            return a;
         else if(a==0)
            return b;  
         else if(a>b)
            gcd(a%b,b);
         else if(a<b)
            gcd(a,b%a);
         else if(a==b)
            return a;
         return 0;
    }
}