#include <bits/stdc++.h>
using namespace std;
vector<int> v[1010];
bool dfs(int i) {
  bool t = true;
  int cnt = 0;
  if (v[i].size()) {
    for (int j = 0; j < v[i].size(); j++) {
      if (v[v[i][j]].size() == 0)
        cnt++;
      else
        t &= dfs(v[i][j]);
    }
  }
  return t & !(v[i].size() && cnt < 3);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  ;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x;
    cin >> x;
    v[x].push_back(i);
  }
  if (dfs(1))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
