#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

#define pr(a) cerr<<#a<<"="<<a<<endl
#define pri(a,lo) {cerr<<#a<<"={";for (int ol=0;ol<=lo;ol++)cerr<<a[ol]<<",";cerr<<"}\n";}
  
typedef long long ll;
typedef pair <int, int> ii;
  
const int mod = 1000000007;
const int Maxn = 200005;
const int Maxm = 20;
  
int pw2[Maxn];
int n;
vector <int> neigh[Maxn];
int cur, lef[Maxn], rig[Maxn];
int L[Maxn], P[Maxn][Maxm];
vector <int> inlvl[Maxn];
int res;
vector <int> tneigh[Maxn];
int res0[Maxn], res1[Maxn];
  
void Traverse(int v)
{
    lef[v] = ++cur;
    inlvl[L[v]].push_back(v);
    for (int i = 0; i < neigh[v].size(); i++) {
        int u = neigh[v][i];
        L[u] = L[v] + 1; P[u][0] = v;
        Traverse(u);
    }
    rig[v] = cur;
}
  
int getLCA(int a, int b)
{
    if (L[a] < L[b]) swap(a, b);
    for (int i = Maxm - 1; i >= 0; i--)
        if (L[a] - (1 << i) >= L[b])
            a = P[a][i];
    if (a == b) return a;
    for (int i = Maxm - 1; i >= 0; i--)
        if (P[a][i] != P[b][i])
            a = P[a][i], b = P[b][i];
    return P[a][0];
}
  
int Inv(int a)
{
    int p = mod - 2;
    int res = 1;
    while (p) {
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}
  
void Compute(int v)
{
    if (tneigh[v].empty()) {
        res0[v] = 1; res1[v] = 1;
        return;
    }
    int all = 1, zers = 1;
    int nils = 0;
    for (int i = 0; i < tneigh[v].size(); i++) {
        int u = tneigh[v][i];
        Compute(u);
        all = ll(all) * (res0[u] + res1[u]) % mod;
        zers = ll(zers) * res0[u] % mod;
    }
    res1[v] = 0;
    for (int i = 0; i < tneigh[v].size(); i++) {
        int u = tneigh[v][i];
        int my;
        if (res0[u] == 0) my = ll(zers) * res1[u] % mod;
        else  my = ll(zers) * Inv(res0[u]) % mod * res1[u] % mod;
        res1[v] = (res1[v] + my) % mod;
    }
    res0[v] = (all - res1[v] + mod) % mod;
}
  
int Solve(int lvl)
{
    vector <ii> seq;
    for (int i = 0; i < inlvl[lvl].size(); i++) {
        int v = inlvl[lvl][i];
        seq.push_back(ii(lef[v], v));
        if (i > 0) {
            int u = inlvl[lvl][i - 1];
            int lca = getLCA(u, v);
            seq.push_back(ii(lef[lca], lca));
        }
    }
    sort(seq.begin(), seq.end()); seq.erase(unique(seq.begin(), seq.end()), seq.end());
    for (int i = 0; i < seq.size(); i++)
        tneigh[seq[i].second].clear();
    vector <int> S;
    //for (int i=0;i<seq.size();i++) printf("v:%d %d\n",seq[i].second,seq[i].first);
    for (int i = 0; i < seq.size(); i++) {
        int v = seq[i].second;
        while (!S.empty() && rig[S.back()] < seq[i].first) S.pop_back();
        if (!S.empty()) tneigh[S.back()].push_back(seq[i].second);//,cerr<<S.back()<<"->"<<seq[i].second<<endl;
        S.push_back(seq[i].second);
    }
    //cout<<endl;
    Compute(seq[0].second);
    return res1[seq[0].second];
}
  
int main()
{
    pw2[0] = 1;
    for (int i = 1; i < Maxn; i++)
        pw2[i] = 2ll * pw2[i - 1] % mod;
    scanf("%d", &n); n++;
    for (int i = 2; i <= n; i++) {
        int p; scanf("%d", &p); p++;
        neigh[p].push_back(i);
    }
    Traverse(1);
    //pri(lef,n+1);
   // pri(rig,n+1);
    for (int j = 1; j < Maxm; j++)
        for (int i = 1; i <= n; i++)
            P[i][j] = P[P[i][j - 1]][j - 1];
    for (int i = 0; i <= n; i++) if (inlvl[i].size() > 0)
        res = (res + ll(Solve(i)) * pw2[n - int(inlvl[i].size())]) % mod;
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 53376