#include <bits/stdc++.h>
using namespace std;
int visit[1005];
int cnt[1005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> vec[1005];
  for (int i = 2; i <= n; i++) {
    int a;
    cin >> a;
    visit[a] = 1;
    vec[a].push_back(i);
    cnt[a]++;
  }
  for (int i = 1; i <= 1004; i++) {
    for (int j = 0; j < vec[i].size(); j++) {
      int z = vec[i][j];
      if (visit[z] == 1) cnt[i]--;
      if (cnt[i] < 3) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
