#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int main() {
  int i, j;
  int n, pare[maxn], mark[maxn];
  while (scanf("%d", &n) != EOF) {
    memset(pare, 0, sizeof(pare));
    memset(mark, 0, sizeof(mark));
    for (i = 2; i <= n; i++) {
      scanf("%d", &pare[i]);
      mark[pare[i]] = 1;
    }
    for (i = n; i >= 2; i--)
      if (mark[i] == 0) {
        mark[pare[i]]++;
      }
    for (i = 1; i <= n; i++) {
      if (mark[i] != 0 && mark[i] < 4) break;
    }
    if (i == (n + 1))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
