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.util.*;
	import java.io.*;
	public class Main {
		
		static InputReader in=new InputReader(System.in);
		static PrintWriter out=new PrintWriter(System.out);
		public static void main(String args[])
		{
			int i,j;
			int T=1;//in.readInt();
			while(T-->0)
			{
				int N=in.readInt();
				Set tree[]=new HashSet[N+1];
				for(i=1;i<N;i++)
				{
					int x=in.readInt();
					if(tree[x]==null)
						tree[x]=new HashSet<Integer>();
					tree[x].add(i+1);
				}
				int ans[]=new int[N+1]; 
				dfs(tree,1,ans);
				boolean flag=true;
				for(i=1;i<=N;i++)
				{
					if(tree[i]!=null&&ans[i]<3)
					{
						flag=false;
						break;
					}
				}
				if(flag)
					out.println("Yes");
				else
					out.println("No");
			}
			out.flush();
			out.close();
		} 
		public static int dfs(Set<Integer> tree[],int root,int x[])
		{
			if(tree[root]==null)
			{
				return 1;
			}
			else
			{
				for(int val:tree[root])
				{
					x[root]+=dfs(tree,val,x);
				}
				return 0;
			}
		}
	}
	class InputReader{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		
		public InputReader(InputStream stream){this.stream = stream;}
		public int read(){
			if (numChars==-1) throw new InputMismatchException();
			if (curChar >= numChars){
				curChar = 0;
				try {numChars = stream.read(buf);}
				catch (IOException e){throw new InputMismatchException();}
				if(numChars <= 0) return -1;
			}
			return buf[curChar++];
		}
	 
		public int readInt(){
			int c = read();
			while(isSpaceChar(c)) c = read();
			int sgn = 1;
			if (c == '-') {sgn = -1;c = read();}
			int res = 0;
			do {
				if(c<'0'||c>'9') throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c)); return res * sgn;
		}
		public void inputI0(int a[],int n)
		{
			for(int i=0;i<n;i++)
				a[i]=readInt();
		}
		public void inputI1(int a[],int n)
		{
			for(int i=1;i<=n;i++)
				a[i]=readInt();
		}
		public long readLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
	      }
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
	      }
			while (!isSpaceChar(c));
	          return res * sgn;
	  }
		public void inputL0(long a[],int n)
		{
			for(int i=0;i<n;i++)
				a[i]=readLong();
		}
		public void inputL1(long a[],int n)
		{
			for(int i=1;i<=n;i++)
				a[i]=readLong();
		}
		public double readDouble() {
	      int c = read();
	      while (isSpaceChar(c))
	          c = read();
	      int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
	      }
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, readInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
	      }
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, readInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
	          }
	      }
			return res * sgn;
	  }
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
	 
		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}
	 
		public String next() {
			return readString();
		}
		
		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}