#include <bits/stdc++.h>
using namespace std;
int a[1100000], m, n, b[1100000], v[1100000];
int main() {
  cin >> m;
  for (int x = 2; x <= m; x++) {
    cin >> a[x];
  }
  for (int x = 2; x <= m; x++) {
    b[a[x]]++;
    v[a[x]]++;
    if (a[a[x]] != 0) {
      if (a[x] <= x) {
        b[a[a[x]]]--;
      }
      a[a[x]] = 0;
    }
  }
  for (int x = 1; x <= m; x++) {
    if (b[x] != 0 && b[x] < 3) {
      n = 1;
      break;
    }
    if (b[x] == 0 && v[x] != 0) {
      n = 1;
      break;
    }
  }
  if (n == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
