Problem: Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices.

Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offices of the bank following the same route every day. The collectors started from the central department and moved between some departments or between some department and some office using special roads. Finally, they returned to the central department. The total number of departments and offices was n, the total number of roads was n - 1. In other words, the special roads system was a rooted tree in which the root was the central department, the leaves were offices, the internal vertices were departments. The collectors always followed the same route in which the number of roads was minimum possible, that is 2n - 2.

One of the collectors said that the number of offices they visited between their visits to offices a and then b (in the given order) is equal to the number of offices they visited between their visits to offices b and then a (in this order). The other collector said that the number of offices they visited between their visits to offices c and then d (in this order) is equal to the number of offices they visited between their visits to offices d and then c (in this order). The interesting part in this talk was that the shortest path (using special roads only) between any pair of offices among a, b, c and d passed through the central department.

Given the special roads map and the indexes of offices a, b, c and d, determine if the situation described by the collectors was possible, or not.

Input

The first line contains single integer n (5 ≤ n ≤ 5000) — the total number of offices and departments. The departments and offices are numbered from 1 to n, the central office has index 1.

The second line contains four integers a, b, c and d (2 ≤ a, b, c, d ≤ n) — the indexes of the departments mentioned in collector's dialogue. It is guaranteed that these indexes are offices (i.e. leaves of the tree), not departments. It is guaranteed that the shortest path between any pair of these offices passes through the central department.

On the third line n - 1 integers follow: p2, p3, ..., pn (1 ≤ pi < i), where pi denotes that there is a special road between the i-th office or department and the pi-th department.

Please note the joint enumeration of departments and offices.

It is guaranteed that the given graph is a tree. The offices are the leaves, the departments are the internal vertices.

Output

If the situation described by the cash collectors was possible, print "YES". Otherwise, print "NO".

Examples

Input

5
2 3 4 5
1 1 1 1


Output

YES

Input

10
3 8 9 10
1 2 2 2 2 2 1 1 1


Output

NO

Input

13
13 12 9 7
1 1 1 1 5 5 2 2 2 3 3 4


Output

YES

Note

In the first example the following collector's route was possible: <image>. We can note that between their visits to offices a and b the collectors visited the same number of offices as between visits to offices b and a; the same holds for c and d (the collectors' route is infinite as they follow it each day).

In the second example there is no route such that between their visits to offices c and d the collectors visited the same number of offices as between visits to offices d and c. Thus, there situation is impossible. 

In the third example one of the following routes is: <image>.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, a, b, c, d;
vector<int> g[5050];
int par[5050];
int cnt[5050];
vector<int> v;
int gettype(int x) {
  int last = -1;
  while (x != 0) {
    last = x;
    x = par[x];
  }
  return last;
}
void dfs(int v) {
  cnt[v] = ((int)g[v].size() == 0);
  for (__typeof(g[v].begin()) it = g[v].begin(); it != g[v].end(); it++) {
    dfs(*it);
    cnt[v] += cnt[*it];
  }
}
void print(vector<int> &v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
vector<int> get_all_submask(vector<int> &values) {
  const int MAX_SIZE = 5050 * 2;
  bitset<MAX_SIZE> dp;
  dp[0] = 1;
  for (__typeof(values.begin()) it = values.begin(); it != values.end(); it++) {
    int value = *it;
    dp |= (dp << value);
  }
  vector<int> ans;
  for (int i = 0; i < MAX_SIZE; i++) {
    if (dp[i]) ans.push_back(i);
  }
  return ans;
}
vector<int> get(int local_root, int leaf) {
  int leaf_degree = 0;
  int x = leaf;
  vector<int> values;
  while (x != 0) {
    int y = par[x];
    leaf_degree++;
    if (y != 0) {
      for (__typeof(g[y].begin()) it = g[y].begin(); it != g[y].end(); it++) {
        int to = *it;
        if (to != x) values.push_back(cnt[to]);
      }
    }
    x = y;
  }
  vector<int> ans = get_all_submask(values);
  for (int i = 0; i < ans.size(); i++) {
    ans[i] += 1;
  }
  return ans;
}
vector<int> get_diff(vector<int> &a, vector<int> &b) {
  int mx = 5050 * 2;
  const int MAX_SZ = 5050 * 2 * 2 + 100;
  bitset<MAX_SZ> dp;
  for (int i = 0; i < a.size(); i++) {
    dp[a[i]] = 1;
  }
  bitset<MAX_SZ> ans;
  for (int i = 0; i < b.size(); i++) {
    ans |= (dp << (mx - b[i]));
  }
  vector<int> values;
  for (int i = 0; i < MAX_SZ; i++) {
    if (ans[i]) values.push_back(i - mx);
  }
  return values;
}
bool solve(int a, int b, int c, int d) {
  int ta = gettype(a);
  int tb = gettype(b);
  int tc = gettype(c);
  int td = gettype(d);
  v.clear();
  for (__typeof(g[0].begin()) it = g[0].begin(); it != g[0].end(); it++) {
    int x = *it;
    if (x != ta && x != tb && x != tc && x != td) v.push_back(cnt[x]);
  }
  vector<int> va = get(ta, a);
  vector<int> vb = get(tb, b);
  vector<int> vc = get(tc, c);
  vector<int> vd = get(td, d);
  int sa = cnt[ta];
  int sb = cnt[tb];
  int sc = cnt[tc];
  int sd = cnt[td];
  int m = cnt[0];
  vector<int> diff_ab = get_diff(vb, va);
  vector<int> diff_cd = get_diff(vd, vc);
  vector<int> values = get_all_submask(v);
  vector<int> is_value(2 * n, 0);
  for (__typeof(values.begin()) it = values.begin(); it != values.end(); it++)
    is_value[*it] = 1;
  for (__typeof(diff_ab.begin()) it = diff_ab.begin(); it != diff_ab.end();
       it++) {
    for (__typeof(diff_cd.begin()) it1 = diff_cd.begin(); it1 != diff_cd.end();
         it1++) {
      int x = *it;
      int y = *it1;
      x = m / 2 - sa - sc - x;
      y = m / 2 - sc - sb - y;
      if (x >= 0 && x < 2 * n && y >= 0 && y < 2 * n) {
        if (is_value[x] && is_value[y]) return true;
      }
    }
  }
  return false;
}
int main() {
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  a--;
  b--;
  c--;
  d--;
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    x--;
    g[x].push_back(i);
    par[i] = x;
  }
  par[0] = -1;
  dfs(0);
  if (cnt[0] % 2)
    printf("NO\n");
  else if (solve(a, b, c, d) || solve(a, b, d, c))
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}