//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}



const int N = 200005;
int n, idx[N], subtree[N];
vector<int> adj[N], DP[N][2], multiplier[N];


void dfs(int v){

    subtree[v] = 1;
    if(adj[v].empty()){
        idx[v] = v;
        multiplier[v].resize(1);
        DP[v][0].resize(1);
        DP[v][1].resize(1);
        multiplier[v][0] = 1;   DP[v][0][0] = 1;    DP[v][1][0] = 1;

// cout<<"after v = "<<v<<endl;
// cout<<"multiplier: ";for(int i=0;i<(int)DP[idx[v]][0].size();i++)   cout<<i<<":"<<multiplier[idx[v]][i]<<" ";cout<<endl;
// cout<<"DP[0]: ";for(int i=0;i<(int)DP[idx[v]][0].size();i++)    cout<<i<<":"<<DP[idx[v]][0][i]<<" ";cout<<endl;
// cout<<"DP[1]: ";for(int i=0;i<(int)DP[idx[v]][1].size();i++)    cout<<i<<":"<<DP[idx[v]][1][i]<<" ";cout<<endl;
// cout<<endl;

        return;
    }

    if((int)adj[v].size() == 1){
        
        dfs(adj[v][0]);
        subtree[v] += subtree[adj[v][0]];

        idx[v] = idx[adj[v][0]];
        int u = idx[v];

        multiplier[u].pb(1);    DP[u][0].pb(pwr(2, subtree[v]-1));  DP[u][1].pb(pwr(2, subtree[v]-1));
        multiplier[u][(int)multiplier[u].size()-2] = (multiplier[u][(int)multiplier[u].size()-2] * 2LL) % MOD;

// cout<<"after v = "<<v<<endl;
// cout<<"multiplier: ";for(int i=0;i<(int)DP[u][0].size();i++)    cout<<i<<":"<<multiplier[u][i]<<" ";cout<<endl;
// cout<<"DP[0]: ";for(int i=0;i<(int)DP[u][0].size();i++) cout<<i<<":"<<DP[u][0][i]<<" ";cout<<endl;
// cout<<"DP[1]: ";for(int i=0;i<(int)DP[u][1].size();i++) cout<<i<<":"<<DP[u][1][i]<<" ";cout<<endl;
// cout<<endl;

        return;
    }

    idx[v] = 0;
    for(auto vv : adj[v]){
        dfs(vv);
        subtree[v] += subtree[vv];
        if((int)multiplier[idx[vv]].size() > (int)multiplier[idx[v]].size())
            idx[v] = idx[vv];
    }

// cout<<idx[v]<<endl;

    int sz = 0, chosen = -1;
    for(auto vv : adj[v]){
        if(idx[vv] == idx[v]){
            chosen = vv;
            continue;
        }
        sz = max(sz, (int)multiplier[idx[vv]].size());
    }

// cout<<sz<<endl;

    vector<int> tottemp(sz, 1), dp0temp(sz, 1), dp1by0temp(sz, 0);
    for(auto vv : adj[v]){
        
        int x = (int)multiplier[idx[vv]].size();
        for(int j=0;j<sz && j<x;j++){
            
            DP[idx[vv]][0][x-1-j] = (DP[idx[vv]][0][x-1-j] * 1LL * multiplier[idx[vv]][x-1-j]) % MOD;
            DP[idx[vv]][1][x-1-j] = (DP[idx[vv]][1][x-1-j] * 1LL * multiplier[idx[vv]][x-1-j]) % MOD;
            if(j+1 < x) multiplier[idx[vv]][x-1-j-1] = (multiplier[idx[vv]][x-1-j-1] * 1LL * multiplier[idx[vv]][x-1-j]) % MOD;
            multiplier[idx[vv]][x-1-j] = 1;
            
            tottemp[j] = (tottemp[j] * (DP[idx[vv]][0][x-1-j]*1LL + DP[idx[vv]][1][x-1-j])) % MOD;
            dp0temp[j] = (dp0temp[j] * 1LL * DP[idx[vv]][0][x-1-j]) % MOD;
            dp1by0temp[j] = (dp1by0temp[j] + DP[idx[vv]][1][x-1-j]*1LL*pwr(DP[idx[vv]][0][x-1-j], MOD-2)%MOD) % MOD;
        }

        int temp = pwr(2, subtree[vv]);
        for(int j=x;j<sz;j++){
            tottemp[j] = (tottemp[j] * 1LL * temp) % MOD;
            dp0temp[j] = (dp0temp[j] * 1LL * temp) % MOD;
        }
    }


// cout<<"after v = "<<v<<endl;
// cout<<"tottemp: ";for(int i=0;i<sz;i++) cout<<tottemp[i]<<" ";cout<<endl;
// cout<<"dp0temp: ";for(int i=0;i<sz;i++) cout<<dp0temp[i]<<" ";cout<<endl;
// cout<<"dp1by0temp: ";for(int i=0;i<sz;i++)  cout<<dp1by0temp[i]<<" ";cout<<endl;


    int u = idx[v];
    for(int j=0;j<sz;j++){
        int i = (int)multiplier[u].size() - 1 - j;
        DP[u][1][i] = dp0temp[j]*1LL*dp1by0temp[j] % MOD;
        DP[u][0][i] = (tottemp[j] - DP[u][1][i]) % MOD;
    }
    multiplier[u].pb(1);    DP[u][0].pb(pwr(2, subtree[v]-1));  DP[u][1].pb(pwr(2, subtree[v]-1));
    multiplier[u][(int)multiplier[u].size()-2] = (multiplier[u][(int)multiplier[u].size()-2] * 2LL) % MOD;
    if(sz+2 <= (int)multiplier[u].size())    multiplier[u][(int)multiplier[u].size()-sz-2] = (multiplier[u][(int)multiplier[u].size()-sz-2] * 1LL * pwr(2, subtree[v] - 1 - subtree[chosen])) % MOD;

// cout<<"multiplier: ";for(int i=0;i<(int)DP[u][0].size();i++)    cout<<i<<":"<<multiplier[u][i]<<" ";cout<<endl;
// cout<<"DP[0]: ";for(int i=0;i<(int)DP[u][0].size();i++) cout<<i<<":"<<DP[u][0][i]<<" ";cout<<endl;
// cout<<"DP[1]: ";for(int i=0;i<(int)DP[u][1].size();i++) cout<<i<<":"<<DP[u][1][i]<<" ";cout<<endl;
// cout<<endl;
}


int main(){
 
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);

    int t=1;;
    // scanf("%d", &t);
    // t=10;
    while(t--){
            
        scanf("%d", &n);
        n++;
        for(int i=1;i<=n;i++){
            adj[i].clear();
            multiplier[i].clear();
            DP[i][0].clear();   DP[i][1].clear();
        }

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

        dfs(1);
        int ans = 0, sz = (int)multiplier[idx[1]].size();
        for(int i=sz-1;i>=0;i--){
            DP[idx[1]][1][i] = (DP[idx[1]][1][i] * 1LL * multiplier[idx[1]][i]) % MOD;
            if(i > 0)   multiplier[idx[1]][i-1] = (multiplier[idx[1]][i-1] * 1LL * multiplier[idx[1]][i]) % MOD;
            multiplier[idx[1]][i] = 1;
            ans = (ans + 1LL*DP[idx[1]][1][i]) % MOD;
        }
        ans += MOD;
        ans %= MOD;
        printf("%d\n", ans);        
    }

    return 0;
}







Measured memory_bytes: 63716