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 C {
	static PrintWriter pw;
	static BufferedReader br;
	static StringBuilder sb;
	static int inf = (int) 1e9;
	static long mod = (long) 1e9 + 7;
	static long[][][] memo;
	static ArrayList<Integer> primes;
	static ArrayList<Integer>[] arr;
	static int n, k, m;
	static boolean[] vis;
	static HashSet<Integer> hs;
	static HashMap<Integer, Integer> hm;
	static HashSet<Integer> pr;
	static int[] ans, h1, h2;
	static int[] si;
	static int[] in;
	static HashMap<Integer, Integer> factors;
	static int[] fac, a, b;
	static int[] l, r;
	static int[] numc;
	static pair[] ed;
	static ArrayList<Integer>[] np;
	static TreeMap<pair, Integer> tm;
	static char[] h;
	static pair[] mm;

	static int[] isComposite;
	static int[] idx;
	static int[] p;

	static void sieve(int N) // O(N log log N)
	{
		isComposite = new int[N + 1];
		idx = new int[N + 1];
		isComposite[0] = isComposite[1] = 1; // 0 indicates a prime number
		primes = new ArrayList<Integer>();

		int ix = 1;
		for (int i = 2; i <= N; ++i) // can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) // can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				idx[i] = ix;
				ix++;
				if (1l * i * i <= N)
					for (int j = i * i; j <= N; j += i) // j = i * 2 will not affect performance too much, may alter in
														// modified sieve
						isComposite[j] = 1;
			}
		p = new int[primes.size()];
		int i = 0;
		for (int x : primes) {
			p[i++] = x;
		}
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());
		arr = new ArrayList[n];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = new ArrayList<>();
		}
		for (int i = 1; i < n; i++) {
			int x = Integer.parseInt(br.readLine());
			arr[x - 1].add(i);
		}
		pw.println(check(0) ? "YES" : "NO");
		pw.flush();

	}

	static boolean f;

	static boolean check(int node) {
		int ans = 0;
		boolean f = true;
		for (int v : arr[node]) {
			if (arr[v].size() == 0)
				ans++;
			else
				f &= check(v);
		}
		if (ans < 3)
			f = false;
		return f;
	}

	static long pow(long a, long e) // O(log e)
	{
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static int gcd(int a, int b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			return x - o.x;
		}

	}

	static class triple implements Comparable<triple> {
		int x;
		int y;
		int z;

		public triple(int a, int b, int c) {
			x = a;
			y = b;
			z = c;
		}

		@Override
		public int compareTo(triple o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}
	}
}