#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n], is_parent[n];
  is_parent[1] = 1;
  for (int i = 2; i <= n; i++) is_parent[i] = 0;
  vector<int> vect[n + 1];
  for (int i = 2; i <= n; i++) {
    scanf("%d", &a[i]);
    vect[a[i]].push_back(i);
    is_parent[a[i]] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int temp = 0;
    for (int j = 0; j < vect[i].size(); j++) {
      if (!is_parent[vect[i][j]]) temp++;
    }
    if (is_parent[i] && temp < 3) {
      ans = 1;
      break;
    }
  }
  if (ans == 0)
    printf("%s", "YES");
  else
    printf("%s", "NO");
  printf("\n");
  return 0;
}
