#include <bits/stdc++.h>
using namespace std;
queue<int> q;
void bfs(vector<int> adj[], int n) {
  if (q.empty()) {
    cout << "YES\n";
    exit(0);
  }
  int current = q.front();
  q.pop();
  if (adj[current].size() != 0) {
    int numleaf = 0;
    for (int j = 0; j < adj[current].size(); j++) {
      if (adj[(adj[current][j])].size() == 0)
        numleaf++;
      else
        q.push(adj[current][j]);
    }
    if (numleaf < 3) {
      cout << "NO\n";
      exit(0);
    }
  }
  bfs(adj, n);
}
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  a[0] = -999;
  a[1] = -999;
  for (int i = 2; i <= n; i++) cin >> a[i];
  vector<int> adj[n + 1];
  for (int i = 2; i <= n; i++) adj[a[i]].push_back(i);
  q.push(1);
  bfs(adj, n);
}
