#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<deque<int>,deque<int> > P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

vector<int> G[MAX_N];

ll add(ll x,ll y)
{
    return (x + y)%MOD;
}

ll sub(ll x,ll y)
{
    return (x+MOD-y)%MOD;
}

ll mul(ll x,ll y)
{
    return x*y%MOD;
}

ll mod_pow(ll a,ll b)
{
    a %= MOD;
    ll res = 1;
    while(b){
        if(b & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

P dfs(int u,int p)
{
    P res;
    vector<P> vec;
    int sz = 0;
    each(v,G[u]){
        if(v != p){
            P nx = dfs(v,u);
            if(len(res.fi) < len(nx.fi)){
                swap(res,nx);
            }
            cmx(sz,len(nx.fi));
            if(len(nx.fi)){
                vec.pb(nx);
            }
        }
    }
    P nw = P(deque<int>(sz),deque<int>(sz));
    rep(i,sz){
        nw.fi[i] = res.fi[i], nw.se[i] = res.se[i];
        res.fi[i] = res.se[i] = 0;
    }
    vector<int> ml(sz,1),al(sz,1);
    rep(i,len(vec)){
        rep(j,len(vec[i].fi)){
            ml[j] = mul(ml[j],vec[i].fi[j]);
            al[j] = mul(al[j],add(vec[i].fi[j],vec[i].se[j]));
        }
    }
    rep(j,sz){
        ml[j] = mul(ml[j],nw.fi[j]);
        al[j] = mul(al[j],add(nw.fi[j],nw.se[j]));
    }
    rep(i,len(vec)){
        rep(j,len(vec[i].fi)){
            res.se[j] = add(res.se[j],mul(vec[i].se[j],mul(ml[j],mod_pow(vec[i].fi[j],MOD-2))));
        }
    }
    rep(j,sz){
        res.se[j] = add(res.se[j],mul(nw.se[j],mul(ml[j],mod_pow(nw.fi[j],MOD-2))));
    }
    rep(j,sz){
        res.fi[j] = sub(al[j],res.se[j]);
    }
    res.fi.push_front(1),res.se.push_front(1);
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        G[a].pb(i+1);
    }
    auto res = dfs(0,-1);
    int ans = 0;
    int al = 1;
    rep(i,len(res.fi)){
        al = mul(al,add(res.fi[i],res.se[i]));
    }
    rep(i,len(res.fi)){
        ans = add(ans,mul(res.se[i],mul(al,mod_pow(add(res.fi[i],res.se[i]),MOD-2))));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 358624