#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> pin;

const int N = 1e5 + 5;
const ll P = 1e9 + 7;

int n;
ll a[N], ans;
vector <ll> vec;

template <typename T>
inline void read(T &X) {
    char ch = 0; T op = 1; 
    for (X = 0; ch > '9' || ch < '0'; ch = getchar())
        if (ch == '-') op = -1;
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        X = (X * 10) + ch - '0';
    X *= op;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("sample.in", "r", stdin);
    clock_t st_clock = clock();
#endif

    read(n);
    for (int i = 1; i <= n; i++) {
        read(a[i]);
        vec.push_back(a[i]);
    }
    sort(vec.begin(), vec.end());
    vector<ll>::iterator end = unique(vec.begin(), vec.end());
	vec.erase(end, vec.end());
    for (int i = 0; i < vec.size(); i++) a[i] = vec[i] - (i == 0 ? 0LL : vec[i - 1]);
    ans = 1;
    for (int i = 0; i < vec.size(); i++) {
        ans = ans * (a[i] + 1) % P;
    }
    printf("%lld\n", ans);

#ifndef ONLINE_JUDGE
    clock_t ed_clock = clock();
    printf("time = %f ms\n", (double)(ed_clock - st_clock) / CLOCKS_PER_SEC * 1000);
#endif
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 1e5 + 10;
const int MAXM = 1e5 + 10;
struct edge {
    int u,v;
    int next;
}e[MAXM * 2];
int first[MAXN];
int idx;
int n;
void add(int a, int b) {
    e[idx].u = a;
    e[idx].v = b;
    e[idx].next = first[a];
    first[a] = idx++;
}
void init() {
    fill(first, first + n + 1, -1);
    idx = 0;
}
int sz[MAXN];
int dp[MAXN];
struct node {
    int val1, val2;
};
bool cmp(node x, node y) {
    return x.val1 - x.val2 < y.val1 - y.val2;
}
void dfs(int u) {
    sz[u] = 1;
    dp[u] = 1;
    vector<node> v1, v2;
    for (int i = first[u]; i != -1; i = e[i].next) {
        int v = e[i].v;
        dfs(v);
        sz[u] += sz[v];
        if (sz[v] % 2) {
            v1.push_back({dp[v], sz[v] - dp[v]});
        } else {
            v2.push_back({dp[v], sz[v] - dp[v]});
        }
    }
    sort(v1.begin(), v1.end(), cmp);
    sort(v2.begin(), v2.end(), cmp);
    int sz1 = v1.size();
    int sz2 = v2.size();
    int now = 0;
    while (now < sz2 && v2[now].val2 - v2[now].val1 >= 0) {
        dp[u] += v2[now].val1;
        now++;
    }
    for (int i = 0; i < sz1; i++) {
        if (i % 2 == 0) {
            dp[u] += v1[i].val1;
        } else {
            dp[u] += v1[i].val2;
        }
    }
    for (int i = now; i < sz2; i++) {
        if (sz1 % 2 == 1) {
            dp[u] += v2[i].val2;
        } else {
            dp[u] += v2[i].val1;
        }
    }
}
int main() {
    scanf("%d", &n);
    init();
    for (int i = 2; i <= n; i++) {
        int fa;
        scanf("%d", &fa);
        add(fa, i);
    }
    dfs(1);
    printf("%d\n", dp[1]);
    return 0;
}