#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int) 2e5 + 10;
const int MOD  = (int) 1e9 + 7;
int n;
vector<int> adj[MAXN];

int h[MAXN], p[MAXN][21];
int dp[MAXN], f[MAXN][2];
int a[MAXN], b[MAXN], c[MAXN];
vector<int> G[MAXN];
vector<int> H[MAXN];
int S[MAXN];

void BFS(int s) {
    queue<int> Q; Q.push(s);
    while (Q.size()) {
        int u = Q.front(); Q.pop();
        H[h[u]].push_back(u);
        for (int i = 0; i < (int) adj[u].size(); ++i) {
            int v = adj[u][i];
            h[v] = h[u] + 1;
            p[v][0] = u;
            Q.push(v);
        }
    }
    for (int j = 1; j <= 20; ++j)
        for (int i = 1; i <= n; ++i)
            p[i][j] = p[p[i][j - 1]][j - 1];
}

int LCA(int u, int v) {
    if (h[u] < h[v]) swap(u, v);
    for (int i = 20; i >= 0; --i)
        if (h[u] - (1 << i) >= h[v]) u = p[u][i];
    if (u == v) return u;
    for (int i = 20; i >= 0; --i)
        if (p[u][i] != p[v][i]) u = p[u][i], v = p[v][i];
    return p[u][0];
}

int Power(int a, int k) {
    int ans = 1;
    while (k) {
        if (k & 1) ans = (LL) ans * a % MOD;
        a = (LL) a * a % MOD;
        k >>= 1;
    }
    return ans;
}

void DFS(int u) {
    sort(G[u].begin(), G[u].end());
    G[u].resize(unique(G[u].begin(), G[u].end()) - G[u].begin());
    c[u] = 0;
    if ((int) G[u].size() == 0) {
        c[u] = 1;
        f[u][0] = 1;
        f[u][1] = 1;
        G[u].clear();
        return;
    }
    int mul = 1;
    for (int i = 0; i < (int) G[u].size(); ++i) {
        int v = G[u][i];
        DFS(v);
        c[u] += c[v];
        mul = (LL) mul * f[v][0] % MOD;
    }
    f[u][1] = 0;
    for (int i = 0; i < (int) G[u].size(); ++i) {
        int v = G[u][i];
        f[u][1] = (f[u][1] + (LL) f[v][1] * mul % MOD * Power(f[v][0], MOD - 2)) % MOD;
    }
    f[u][0] = (Power(2, c[u]) - f[u][1] + MOD) % MOD;
    G[u].clear();
}

void AddEdge(int u, int v) {
    if (u == v) return;
    G[u].push_back(v);
    // printf("%d %d\n", u, v);
}

int main() {
    scanf("%d", &n); n++;
    for (int i = 2; i <= n; ++i) {
        int x; scanf("%d", &x);
        adj[x + 1].push_back(i);
    }

    int ans = 0; BFS(1);
    for (int t = 0; t <= n; ++t) {
        int k = (int) H[t].size();
        if (k == 0) {
            printf("%d\n", ans);
            return 0;
        }
        for (int i = 1; i <= k; ++i) a[i] = H[t][i - 1];
        
        int root = LCA(a[1], a[k]);
        int top = 0;
        S[++top] = root;
        for (int i = 1; i <= k; ++i) {
            int p = LCA(S[top], a[i]);
            while (1) {
                if (top == 1 || h[S[top - 1]] <= h[p]) {
                    AddEdge(p, S[top]);
                    top--;
                    if (top == 0 || S[top] != p) S[++top] = p;
                    break;
                }
                AddEdge(S[top - 1], S[top]);
                top--;
            }
            if (top == 0 || S[top] != a[i]) S[++top] = a[i];
        }
        while (top > 1) {
            AddEdge(S[top - 1], S[top]);
            top--;
        }
        
        DFS(root);
        ans = (ans + (LL) f[root][1] * Power(2, n - k)) % MOD;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 48768