#include <bits/stdc++.h>
using namespace std;
int dimx[] = {-1, 1, 0, 0};
int dimy[] = {0, 0, 1, -1};
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else {
    return gcd(b, a % b);
  }
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long Pow(long long base, long long exponent) {
  long long result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % 1000000007;
    exponent = exponent >> 1;
    base = (base * base) % 1000000007;
  }
  return result;
}
long double dis(int x1, int y1, int x2, int y2) {
  return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
bool checklucky(int n) {
  while (n) {
    if (n % 10 != 4 && n % 10 != 7) return false;
    n /= 10;
  }
  return true;
}
int logg2(long long n) {
  int ans = 0;
  while (n) ans++, n /= 2;
  return --ans;
}
int par[10005];
vector<int> vec[10005];
int correct(int x) {
  int ans = 0;
  for (long long c = 0; c < vec[x].size(); c++) {
    if (vec[vec[x][c]].size() > 0) ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0), ios::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
  int n;
  cin >> n;
  int x;
  for (long long c = 0; c < n - 1; c++) {
    cin >> x;
    vec[--x].push_back(c + 1);
  }
  for (long long c = 0; c < n; c++) {
    if (vec[c].size() - correct(c) < 3 && vec[c].size() != 0)
      return cout << "No"
                  << "\n",
             0;
  }
  cout << "Yes"
       << "\n";
  return 0;
}

### Prompt

Generate a cpp solution to the following 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>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dimx[] = {-1, 1, 0, 0};
int dimy[] = {0, 0, 1, -1};
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else {
    return gcd(b, a % b);
  }
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long Pow(long long base, long long exponent) {
  long long result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % 1000000007;
    exponent = exponent >> 1;
    base = (base * base) % 1000000007;
  }
  return result;
}
long double dis(int x1, int y1, int x2, int y2) {
  return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
bool checklucky(int n) {
  while (n) {
    if (n % 10 != 4 && n % 10 != 7) return false;
    n /= 10;
  }
  return true;
}
int logg2(long long n) {
  int ans = 0;
  while (n) ans++, n /= 2;
  return --ans;
}
int par[10005];
vector<int> vec[10005];
int correct(int x) {
  int ans = 0;
  for (long long c = 0; c < vec[x].size(); c++) {
    if (vec[vec[x][c]].size() > 0) ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0), ios::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
  int n;
  cin >> n;
  int x;
  for (long long c = 0; c < n - 1; c++) {
    cin >> x;
    vec[--x].push_back(c + 1);
  }
  for (long long c = 0; c < n; c++) {
    if (vec[c].size() - correct(c) < 3 && vec[c].size() != 0)
      return cout << "No"
                  << "\n",
             0;
  }
  cout << "Yes"
       << "\n";
  return 0;
}

```