// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char a=getchar();
	bool neg=false;
	x=0;
	for(; (a>'9'||a<'0')&&a!='-'&&a!=EOF; a=getchar());
	if(a=='-')neg=true,a=getchar();if(a==EOF)return false;
	for(; a<='9'&&a>='0'; a=getchar())x=x*10+a-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
 
const int mod=1e9+7;
const int rev2=(mod+1)/2;
 
struct data
{
	int a[3];
	data(int t1=0,int t2=0,int t3=0){a[0]=t1;a[1]=t2;a[2]=t3;}
	void clear(){a[0]=a[1]=a[2]=0;}
	data comb(const data&b)
	{
		data ret;
		for(int i=0;i<3;i++)for(int j=0;j<3;j++)
		{
			int k=min(2,i+j);
			ret.a[k]=(ret.a[k]+1ll*a[i]*b.a[j])%mod;
		}
		return ret;
	}
	void reduce(){a[0]+=a[2];if(a[0]>=mod)a[0]-=mod;a[2]=0;}
};
vector<int> g[200111];
vector<data> q[200111];
int n;
void dfs(int x)
{
	int mx=-1;
	for(auto v:g[x]){dfs(v);if(mx==-1||q[mx].size()<q[v].size())mx=v;}
	if(mx!=-1)swap(q[x],q[mx]);
	int tmx=0;
	for(auto v:g[x])
	{
		tmx=max(tmx,(int)q[v].size());
		for(int i=(int)q[x].size()-1;i>=(int)q[x].size()-(int)q[v].size();i--)
			q[x][i]=q[x][i].comb(q[v][i-q[x].size()+q[v].size()]);
	}
	for(int i=(int)q[x].size()-1;i>=(int)q[x].size()-tmx;i--)q[x][i].reduce();
	q[x].pb(data(rev2,rev2,0));
}
int main()
{
	get1(n);for(int i=1,p;i<=n;i++){get1(p);g[p].pb(i);}
	dfs(0);
	int p=1,ans=0;for(int i=0;i<=n;i++)p=p*2%mod;
	for(auto&x:q[0])ans=(ans+1ll*p*x.a[1])%mod;
	printendl(ans);
	return 0;
}