#include <bits/stdc++.h>

using namespace std;

#define MAXN 200010
#define INF 0x3f3f3f3f
#define mo 1000000007
typedef long long LL;

int n;
vector< int > adj[MAXN];
vector< int > L[MAXN];


namespace Least_Common_Ancestors{

    const int LOG = 20;
    int dep[MAXN], fa[MAXN][20];

    void DFS(int u, int f, int l){
        dep[u] = dep[f] + 1;
        fa[u][0] = f;
        L[l].push_back(u);
        for(auto &v : adj[u]){
            if(v == f) continue;
            DFS(v, u, l + 1);
        }
    }

    void Build(int root = 1, int root_dep = -1){
        dep[0] = root_dep; DFS(root, 0, 0);
        for(int j = 1; j < LOG; ++j)
            for(int i = 1; i <= n; ++i)
                fa[i][j] = fa[fa[i][j - 1]][j - 1];
    }

    int LCA(int x, int y){
        if(dep[x] < dep[y]) swap(x, y);
        for(int i = 19; ~i; --i)
            if(dep[x] - (1 << i) >= dep[y])
                x = fa[x][i];
        if(x == y) return x;
        for(int i = 19; ~i; --i)
            if(fa[x][i] != fa[y][i])
                x = fa[x][i], y = fa[y][i];
        return fa[x][0];
    }
}

void Init()
{
    int i, fa;
    scanf("%d", &n); ++n;
    for(i = 2; i <= n; ++i){
        scanf("%d", &fa); ++fa;
        adj[fa].push_back(i);
    }
    Least_Common_Ancestors::Build();
}

int dp[MAXN][2], f[MAXN];
int stk[MAXN];
vector < int > tree[MAXN];
vector< int > s;

void Addedge(int u, int v)
{
    tree[u].push_back(v);
    tree[v].push_back(u);
    s.push_back(u); s.push_back(v);
}

void build(vector< int > p, int k)
{
    int sz = 0; stk[sz++] = 0;
    for(int i = 0; i < k; ++i) {
        int u = p[i], lca = Least_Common_Ancestors::LCA(u, stk[sz - 1]);
        if(lca == stk[sz - 1]) stk[sz++] = u;
        else {
            while (sz - 2 >= 0 && Least_Common_Ancestors::dep[stk[sz - 2]] >= Least_Common_Ancestors::dep[lca]) {
                Addedge(stk[sz - 2], stk[sz - 1]);
                sz--;
            }
            if (stk[sz - 1] != lca) {
                Addedge(lca, stk[--sz]);
                stk[sz++] = lca;
            }
            stk[sz++] = u;
        }
    }
    for(int i = 0; i < sz - 1; ++i) Addedge(stk[i], stk[i + 1]);
}

int POW(int a,int b)
{
    int res;
    for(res = 1; b; (b & 1) && (res = 1LL * res * a % mo), a = 1LL * a * a % mo, b >>= 1);
    return res;
}

void DFS(int u, int fa)
{

    int flag = false;
    dp[u][0] = dp[u][1] = 0;
    int res = 1, res2 = 1;
    for(auto &v: tree[u]){
        if(v == fa) continue;
        DFS(v, u); flag = true;
        res = 1LL * res * (dp[v][0] + dp[v][1]) % mo;
        res2 = 1LL * res2 * dp[v][0] % mo;
    }
    if(!flag) dp[u][0] = dp[u][1] = 1;
    else{
        for(auto &v: tree[u]){
            if(v == fa) continue;
            dp[u][1] = (dp[u][1] + 1LL * res2 * POW(dp[v][0], mo - 2) % mo * dp[v][1]) % mo;
        }
        dp[u][0] = (0LL + res + mo - dp[u][1]) % mo;
    }

}

void Work()
{
    int ans = 0;
    for(int i = 0; i <= n; ++i){
        if((int)L[i].size() == 0) continue;
        build(L[i], L[i].size());
        DFS(0, -1);
        ans = (ans + 1LL * dp[0][1] * POW(2, n - (int)L[i].size())) % mo;
        for(auto &it: s){
            tree[it].clear();
        }
        s.clear();
    }
    printf("%d\n", ans);
}


int main()
{
    Init();
    Work();
	return 0;
}


Measured memory_bytes: 65024