#include <bits/stdc++.h>
using namespace std;
int a[1001], sum[1001], f[1001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[a[i]]++;
  }
  for (int i = 2; i <= n; i++)
    if (!sum[i]) f[a[i]]++;
  for (int i = 1; i <= n; i++)
    if (sum[i] && f[i] < 3) {
      printf("NO\n");
      return 0;
    }
  printf("YES\n");
  return 0;
}
