#include <bits/stdc++.h>
using namespace std;
int nxt[1005][1005];
int n;
int rec(int cur) {
  int leaf = true;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (nxt[cur][i]) {
      leaf = 0;
      int res = rec(i);
      if (res == -1)
        return res;
      else
        sum += res;
    }
  }
  if (leaf)
    return 1;
  else {
    if (sum < 3) return -1;
    return 0;
  }
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int current_node;
    cin >> current_node;
    nxt[current_node][i] = 1;
  }
  int valid = rec(1);
  if (valid != -1)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
