#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int child[N];
int mat[N][N];
int main() {
  cin.sync_with_stdio(false);
  int n, x;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    mat[x][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    child[i] = 1;
    for (int j = 1; j <= n; j++) {
      if (mat[i][j]) {
        child[i] = 0;
        break;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (mat[i][j] && child[j]) cnt++;
    }
    if (!child[i] && cnt < 3) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
