#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,dp[200005],s[200005],b[200005],z[200005],ans;
struct T{
	ll x,y,z,i;
	void plus(T &q){
		z=(z*(q.x+q.y+q.z)%M+y*(q.y+q.z)%M+x*q.z%M)%M;
		y=(y*q.x%M+x*q.y%M)%M;
		x=x*q.x%M;
	}
	void up(int q){
		if(q<i){
			x=(x+z)%M,z=0;
			i=q;
		}
	}
};
vector<int>g[200005];
map<int,T>q[200005];
void dfs(int v,int d){
	dp[v]=d;
	s[d]++;
	for(int i=0;i<g[v].size();i++)dfs(g[v][i],d+1);
}
void merge(int x,int y,int i){
	if(q[b[x]].size()<q[b[y]].size())swap(x,y);
	ll w=b[y];
	x=b[x],b[y]=x;
	auto it=q[w].begin();
	while(it!=q[w].end()){
		it->S.up(i);
		if(q[x].find(it->F)!=q[x].end()){
			q[x][it->F].up(i);
			q[x][it->F].plus(it->S);
		}else q[x].insert(*it);
		it++;
	}
}
void dfs2(int v){
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		dfs2(u);
		merge(v,u,dp[v]);
	}
}
int main(void){
    scanf("%lld",&n);
    n++;
    z[0]=1;
    for(int i=1;i<=n;i++)z[i]=z[i-1]*2LL%M;
    for(int i=1;i<n;i++){
		ll p;
		scanf("%lld",&p);
		g[p].PB(i);
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		b[i]=i;
		q[i].insert(pair<int,T>(dp[i],T{1,1,0,dp[i]}));
	}
	dfs2(0);
	for(auto it=q[b[0]].begin();it!=q[b[0]].end();it++){
		ans=(ans+(it->S.y)*z[n-s[it->F]])%M;
	}
	printf("%lld\n",ans);
}
