#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef deque<int> vi;
typedef pair<int,int> pii;
 
const int MOD = 1e9 + 7;
const int HALF = MOD/2 + 1;
const int N = 2e5 + 10;
 
int n;
vi adj[N];
 
int merge(deque<pii> &a, deque<pii> &b) {
    if (si(a) < si(b)) swap(a,b);
    forn(t,si(b)) {
        a[t].second = ((ll)a[t].first * b[t].second % MOD) + ((ll)a[t].second * b[t].first % MOD);
        if (a[t].second >= MOD) a[t].second -= MOD;
        a[t].first = (ll)a[t].first*b[t].first%MOD;
    }
    return si(b);
}
 
deque<pii> dp[N];
void dfs(int u, int p) {
    dp[u].eb(HALF,HALF);
    int fix = 0;
    for (int v : adj[u]) if (v != p) {
        dfs(v,u);
        dp[v].push_front(mp(1,0));
        fix = max(fix, merge(dp[u], dp[v]));
    }
    forn(t,fix) {
        dp[u][t].first = 1 - dp[u][t].second;
        if (dp[u][t].first < 0) dp[u][t].first += MOD;
    }
 
}
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
    cin >> n;
    forn(i,n) {
        int p; cin >> p;
        adj[p].pb(i+1);
    }
    n++;
    dfs(0,0);
 
    int ans = 0;
    for (auto xy : dp[0]) {
        ans += xy.second;
        if (ans >= MOD) ans -= MOD;
    }
    forn(_,n) ans = 2*ans%MOD;
    cout << ans << endl;
 
    return 0;
}
