#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
struct moduloM{
	ll dat;
	moduloM(ll d=0LL){
		dat=d;
	}
	moduloM(const moduloM& oth){
		dat=oth.dat;
	}
	moduloM operator+(const moduloM& oth)const{
		return moduloM((dat+oth.dat)%INF);
	}
	moduloM operator-(const moduloM& oth)const{
		return moduloM((dat-oth.dat+INF)%INF);
	}
	moduloM operator*(const moduloM& oth)const{
		return moduloM((dat*oth.dat)%INF);
	}
	moduloM operator^(int T)const{
		if(T==0)return moduloM(1LL);
		moduloM ans=operator^(T>>1);
		ans=ans*ans;
		if(T&1)ans=operator*(ans);
		return ans;
	}
	moduloM operator/(const moduloM& oth)const{
		return operator*(oth^(INF-2));
	}
};
istream& operator>>(istream& st,moduloM& got){
	return st>>got.dat;
}
ostream& operator<<(ostream& st,const moduloM& got){
	return st<<got.dat;
}
bool fild[200005];
moduloM mem[200005];
moduloM comb(int T){
	if(fild[T])return mem[T];
	fild[T]=true;
	return mem[T]=moduloM(2)^T;
}
vector<int> G[200005];
vector<pair<moduloM,int> > dp[200005];
int id[200005],cnt;
int dep[200005],md[200005];
void dfs(int v,int par){
	dep[v]=par==-1?0:dep[par]+1;
	md[v]=dep[v];
	int tu=-1,d2=-1;
	rep(k,G[v].size()){
		int u=G[v][k];
		if(u==par)continue;
		dfs(u,v);
		md[v]=max(md[v],md[u]);
		if(md[v]==md[u])tu=u;
	}
	if(tu==-1){
		id[v]=cnt++;
		dp[id[v]].push_back(MP(1LL,1));
		return;
	}
	id[v]=id[tu];
	dp[id[v]].push_back(MP(1LL,1));
	moduloM c1,c2;
	c1=c2=1LL;
	rep(k,G[v].size()){
		int u=G[v][k];
		if(u==par||u==tu)continue;
		d2=max(d2,md[u]);
	}
	if(d2==-1)return;
	vector<pair<moduloM,int> > cc;
	for(int k=md[v]-d2;k<md[v]-dep[v];k++){
		cc.push_back(dp[id[v]][k]);
		dp[id[v]][k]=MP(0LL,0);
	}
	rep(k,G[v].size()){
		int u=G[v][k];
		if(u==par)continue;
		vector<pair<moduloM,int> >& cur=u==tu?cc:dp[id[u]];
		int dd=min(d2,md[u]);
		for(int j=md[v]-dd;j<=md[v]-dep[u];j++){
			dp[id[v]][j].first=dp[id[v]][j].first+cur[j-md[v]+dd].first/(comb(cur[j-md[v]+dd].second)-cur[j-md[v]+dd].first);
			dp[id[v]][j].second+=cur[j-md[v]+dd].second;
		}
	}
	rep(k,G[v].size()){
		int u=G[v][k];
		if(u==par)continue;
		vector<pair<moduloM,int> >& cur=u==tu?cc:dp[id[u]];
		int dd=min(d2,md[u]);
		for(int j=md[v]-dd;j<=md[v]-dep[u];j++)
		dp[id[v]][j].first=dp[id[v]][j].first*(comb(cur[j-md[v]+dd].second)-cur[j-md[v]+dd].first);
	}
}
int main(){
	ios::sync_with_stdio(false);
	int n,p;
	cin>>n;
	rep1(k,n){
		cin>>p;
		G[p].push_back(k);
		G[k].push_back(p);
	}
	dfs(0,-1);
	moduloM cc=1LL,ans;
	rep(k,dp[id[0]].size())cc=cc*comb(dp[id[0]][k].second);
	rep(k,dp[id[0]].size())ans=ans+dp[id[0]][k].first/comb(dp[id[0]][k].second)*cc;
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 66164