#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

vector<ll> stackvec(deque<ll>& s) {
	int n = sz(s);
	vector<ll> tmp(n);
	rep(i, 0, n) {
		tmp[i] = s.front(); s.pop_front();
	}
	rer(i, n, 0) s.push_front(tmp[i]);
	return tmp;
}

int N;
vector<int> G[MAX_N];
deque<ll> S[MAX_N][3];
int dep[MAX_N];

void loop(int v, int d) {
	dep[d]++;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		loop(n, d + 1);
		int mv = sz(S[v][0]), mn = sz(S[n][0]);
		if(mv < mn) {
			rep(k, 0, 3) swap(S[v][k], S[n][k]);
			swap(mv, mn);
		}

		vector<vl> cnt(3, vl(mn, 0));
		vector<ll> vvec(3, 0), nvec(3, 0);

		rep(i, 0, mn) {
			rep(k, 0, 3) {
				if(S[v][k].empty()) vvec[k] = 0;
				else { vvec[k] = S[v][k].front(); S[v][k].pop_front(); }
			}
			rep(k, 0, 3) {
				if(S[n][k].empty()) nvec[k] = 0;
				else { nvec[k] = S[n][k].front(); S[n][k].pop_front(); }
			}
			rep(j, 0, 3) {
				rep(k, 0, 3) {
					ADD(cnt[min(j + k, 2)][i], vvec[j] * nvec[k] % mod);
				}
			}
		}
		rer(i, mn, 0) {
			rep(k, 0, 3) S[v][k].push_front(cnt[k][i]);
		}
	}
	// debug(v, stackvec(S[v][0]), stackvec(S[v][1]), stackvec(S[v][2]));
	vector<ll> zero, one;  
	for(int i = 0; ; i++) {
		if(S[v][2].empty()) break;
		ll v0 = S[v][0].front(); S[v][0].pop_front();
		ll v1 = S[v][1].front(); S[v][1].pop_front();
		ll v2 = S[v][2].front(); S[v][2].pop_front();
		zero.pb((v0 + v2) % mod);
		one.pb(v1);
	}
	rer(i, sz(zero), 0) {
		S[v][0].push_front(zero[i]);
		S[v][1].push_front(one[i]);
	}
	S[v][0].push_front(1);
	S[v][1].push_front(1);
	S[v][2].clear();
	// debug(v, stackvec(S[v][0]), stackvec(S[v][1]), stackvec(S[v][2]));
}

void solve() {
	cin >> N; N++;
	// init(N + 10);
	rep(i, 0, N - 1) {
		int p; cin >> p;
		G[p].pb(i + 1);
	}
	loop(0, 0);
	ll ans = 0;
	int cnt = 0;
	while(!S[0][1].empty()) {
		ll x = S[0][1].front();
		S[0][1].pop_front();
		ADD(ans, x * mod_pow(2, N - dep[cnt]) % mod);
		// debug(x, N - dep[cnt]);
		cnt++;
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 474624