#include <bits/stdc++.h>
const long long MAX = 1e6;
using namespace std;
const long long alpha = 26;
vector<long long> g[MAX];
long long check = 1;
void dfs(long long k) {
  if (!g[k].size()) return;
  long long count = 0;
  for (auto it : g[k]) {
    if (!g[it].size()) count++;
  }
  if (count < 3) check = 0;
  for (auto it : g[k]) dfs(it);
}
void solve() {
  long long n;
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long v;
    cin >> v;
    g[v].push_back(i);
  }
  dfs(1);
  if (check)
    cout << "YES";
  else
    cout << "NO";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
