#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
vector<ll> dp[200010][3];
int N;
int p[200010];
int timer[200010];
int depth[200010];
int mindex[200010];
vector<int> children[200010];
ll num[201000];

ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}

void merge(int a, int b) {
    //cerr << "merge: " << a << " " << b << endl;
    if(timer[a] + dp[a][0].size() < timer[b] + dp[b][0].size()) {
        swap(dp[a][0], dp[b][0]);
        swap(dp[a][1], dp[b][1]);
        swap(dp[a][2], dp[b][2]);
        swap(timer[a], timer[b]);
    }
    int delta = timer[a] - timer[b];
    chmin(mindex[a], delta);
    //cerr << "delta: " << a << " " << b << " " << delta << endl;
    for(int i = 0; i < dp[b][0].size(); i++) {
        if(delta + i == dp[a][0].size()) {
            dp[a][0].push_back(dp[b][0][i]);
            dp[a][1].push_back(dp[b][1][i]);
            dp[a][2].push_back(dp[b][2][i]);
        } else {
            ll zero = dp[a][0][delta+i] * dp[b][0][i];
            zero %= mod;
            ll one = dp[a][1][delta+i] * dp[b][0][i] + dp[a][0][delta+i] * dp[b][1][i];
            one %= mod;
            ll two = dp[a][2][delta+i] * (dp[b][0][i] + dp[b][1][i] + dp[b][2][i]);
            two %= mod;
            two += dp[a][1][delta+i] * (dp[b][1][i] + dp[b][2][i]);
            two %= mod;
            two += dp[a][0][delta+i] * dp[b][2][i];
            two %= mod;
            dp[a][0][delta+i] = zero;
            dp[a][1][delta+i] = one;
            dp[a][2][delta+i] = two;
        }
    }
}

void dfs(int now) {
    num[depth[now]]++;
    //cerr << "------DFS: " << now << "----------" << endl;
    mindex[now] = 1e9;
    dp[now][0].push_back(1); 
    dp[now][1].push_back(1); 
    dp[now][2].push_back(0); 
    //cerr << "hoge" << endl;
    timer[now] = depth[now];
    for(auto to : children[now]) {
        //cerr << now << " -> " << to << endl;
        depth[to] = depth[now] + 1;
        dfs(to);
        merge(now, to);
    }
    //cerr << "children search end : " << now << endl;
    for(int i = mindex[now]; i < dp[now][2].size(); i++) {
        dp[now][0][i] += dp[now][2][i];
        dp[now][0][i] %= mod;
        dp[now][2][i] = 0;
    }
    //cerr << "status of " << now << endl;
    //cerr << timer[now] << endl;
    /*
    for(int i = 0; i < dp[now][1].size(); i++) {
        cerr << dp[now][0][i] << " " << dp[now][1][i] << endl;
    }
    */
    //cerr << "end: " << now << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    p[0] = -1;
    for(int i = 1; i <= N; i++) {
        cin >> p[i];
        children[p[i]].push_back(i);
    }
    dfs(0);
    ll ans = 0;
    for(int i = 0; i < dp[0][1].size(); i++) {
        int d = dp[0][1].size() - i - 1;
        ans += dp[0][1][i] * beki(2, N + 1 - num[d]) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 72280