/***
Smuggling Marbles
2017 12 22
Atcoder Regular Contest 086 problem E 
***/
#include <bits/stdc++.h>

//#define DEBUG 1

//#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 200000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;
long long one_half;

int parent[MAXN+5];
vector<int> children[MAXN+5];
ll pow2[MAXN+5];
int deepest_child[MAXN+5];

long long extended_euclid(long long a, long long b, long long *x, long long *y)
{
    if (a == 0) {
        *x = 0;
        *y = 1;
        return b;
    }
    long long x1,y1,g;
    g = extended_euclid(b%a, a, &x1, &y1);
    *x = y1 - (b/a)*x1;
    *y = x1;
    return g;
}

long long mod_divide(long long a, long long b, long long mod)
{
    long long x,y;
    long long g = extended_euclid(b,mod,&x,&y);
    assert(g == 1);
    x = (x%mod + mod)%mod;
    return (a*x) %mod;
}

int prelim_dfs(int cur)
{
    int max_depth = 0, winner = 0;
    iter(children[cur]) {
        int rec = prelim_dfs(*it);
        if (rec > max_depth) {
            max_depth = rec;
            winner = *it;
        }
    }
    deepest_child[cur] = winner;
    return max_depth+1;
}

void merge(vector<ll> *main_list, vector<vector<ll>*>* others)
{
    /*pr("merge") printv((*main_list))
    for0(i,sz(others)) {
        printv((*others[i]))
    }*/
    vector<int> sizes;
    int max_size = 0;
    for (int i=0; i<others->size(); i++) {
        sizes.push_back((*others)[i]->size());
        max_size = max(max_size, (*others)[i]->size());
    }
    assert(main_list->size() >= max_size);
    
    for (int i=0; i<others->size(); i++) {
        for (int d=0; d<sizes[i]; d++)
            (*(*others)[i])[d] = pmod((1-(*(*others)[i])[d]),MOD);
            //(*(*others)[i])[d] = (1-(*(*others)[i])[d]) % MOD;
    }
    for (int d=0; d<max_size; d++)
        (*main_list)[main_list->size()-d-1] = pmod((1-(*main_list)[main_list->size()-d-1]), MOD);
        //(*main_list)[main_list->size()-d-1] = (1-(*main_list)[main_list->size()-d-1]) % MOD;
    
    for (int d=0; d<max_size; d++) {
        ll k = 1;
        ll p = (*main_list)[main_list->size()-d-1];
        for (int i=0; i<others->size(); i++) {
            if (sizes[i] > d) {
                k++;
                p *= (*(*others)[i])[sizes[i]-d-1];
                p %= MOD;
            }
        }
        //pr(d) pr(p) pr(k) nl
        ll res = 0;
        for (int i=0; i<others->size(); i++) {
            if (sizes[i] > d) {
                res += mod_divide(p, (*(*others)[i])[sizes[i]-d-1], MOD);
                res %= MOD;
            }
        }
        res += mod_divide(p, (*main_list)[main_list->size()-d-1], MOD);
        res -= (k*p)%MOD;
        (*main_list)[main_list->size()-d-1] = res%MOD;
    }
    //printv((*main_list))
    //nl
}

void solve(int cur, vector<ll> * ret_list)
{
    if (sz(children[cur]) == 0) {
        ret_list->push_back(one_half);
    }
    else {
        solve(deepest_child[cur], ret_list);
        vector<vector<ll>*>* recs = new vector<vector<ll>*>();
        iter(children[cur]) {
            if (*it != deepest_child[cur]) {
                vector<ll> * rec = new vector<ll>();
                solve(*it, rec);
                recs->push_back(rec);
            }
        }
        merge(ret_list, recs);
        for0(i,sz(*recs))
            delete (*recs)[i];  
        delete recs;
        ret_list->push_back(one_half);
        //pr("solve") pr(cur) printv((*ret_list))
    }
}

int32_t main()
{
    #ifdef DEBUG
    //freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int n;
    cin >> n;
    for0(i,n) {
        read(parent[i+1]);
        children[parent[i+1]].pb(i+1);
    }
    n++;    
    
    pow2[0] = 1;
    for (int i=1; i<=n; i++)
        pow2[i] = (pow2[i-1]*2) % MOD;
    
    one_half = mod_divide(1,2,MOD);
    
    prelim_dfs(0);
    //printa(deepest_child,n+1);
    
    vector<ll> * res = new vector<ll>();
    solve(0,res);
    ll ans = 0;
    for (int i=0; i<sz((*res)); i++) {
        ans = (ans + (*res)[i]) % MOD;
    }
    ans = (ans*pow2[n]) % MOD;
    ans = pmod(ans,MOD);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 29304