#include <bits/stdc++.h>

using namespace std;

#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;
typedef pair<ll, ll> pll;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int n;
vector<int> adj[MAXN];
int d[MAXN], h[MAXN];
int _sz[MAXN];
ll has[MAXN][3];
ll po2[MAXN];
ll ep[MAXN * 2];
ll vals[MAXN];
int nxt[MAXN], ff[MAXN];

void dfs(int u) {
	_sz[u] = 1;
	ff[u] = u;
	int maxLen = 0;

	vector<pii> vii;

	for(auto v : adj[u]) {
		d[v] = d[u] + 1;
		dfs(v);
		_sz[u] += _sz[v];
		if (h[v] >= maxLen) {
			maxLen = h[v];
		}
		vii.pb(mp(h[v], v));
	}

	sort(vii.begin(), vii.end());

	h[u] = maxLen + 1;

	if (sz(vii)) nxt[u] = vii.back().SE;
	else nxt[u] = -1;

	int pre = -1;
	int h = 0;
	FOR(i, 0, sz(vii) - 1) {
		//if (v == find) continue;
		int t2 = vii[i].SE;
		int t1 = vii[i + 1].SE;
		int j = 0;
		while (~t2) {
			// if (u == 0) cout << has[t2][1] << " " << has[t1][1] << " " << ep[j] << " " << has[t1][0] << endl;
			ep[j] = (has[t2][1] * has[t1][1] + ep[j] * (has[t1][0] + has[t1][1])) % MOD;
			j++;
			h = max(h, j);
			has[t1][1] = (has[t1][1] * has[t2][0] % MOD + has[t2][1] * has[t1][0] % MOD) % MOD;
			has[t1][0] = (has[t1][0] * has[t2][0] % MOD) % MOD;
			t1 = nxt[t1];
			t2 = nxt[t2];
		}
	}
	// int t1 = nxt[u], t2 = pre;
	// while (~t2) {
	// 	ep[j++] = (has[t2][1] * has[t1][1] + ep[j] * (has[t1][0] + has[t1][1])) % MOD;
	// 	has[t1][1] = (has[t1][1] * has[t2][0] % MOD + has[t2][1] * has[t1][0] % MOD) % MOD;
	// 	has[t1][0] = (has[t1][0] * has[t2][0] % MOD) % MOD;
	// 	t1 = nxt[t1];
	// 	t2 = nxt[t2];
	// }

	int t1 = nxt[u];
	FOR(i, 0, h) {
		(has[t1][0] += ep[i]) %= MOD;
		t1 = nxt[t1];
		ep[i] = 0;
	}
	ep[h] = 0;

	has[u][0] = has[u][1] = 1;
	has[u][2] = 0;
}

void calc() {
	ll dp[2];
	dp[0] = 1;
	dp[1] = 0;
	ll res = 0;

	int cur = 0;
	int i = 0;
	vector<int> vi;
	while(~cur) {
		vals[i++] = has[cur][1];
		//(has[cur][0] += has[cur][2]) %= MOD;
		vi.pb(cur);
		cur = nxt[cur];
	}

	FOR(i, 0, sz(vi)) {
		int v = vi[i];
		(vals[i] *= (dp[0] + dp[1])) %= MOD;
		dp[1] = ((dp[0] + dp[1]) * has[v][1] + dp[1] * has[v][0]) % MOD;
		dp[0] = dp[0] * has[v][0] % MOD;
		cur = nxt[cur];
	}

	dp[0] = 1;
	dp[1] = 0;
	FORd(i, sz(vi), 0) {
		int v = vi[i];
		(vals[i] *= (dp[0] + dp[1])) %= MOD;
		dp[1] = ((dp[0] + dp[1]) * has[v][1] % MOD + dp[1] * has[v][0] % MOD) % MOD;
		dp[0] = dp[0] * has[v][0] % MOD;
	}

	FOR(i, 0, sz(vi)) {
		(res += vals[i]) %= MOD;
	}

	cout << res;
}

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("inp.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
// #endif

    po2[0] = 1;
    FOR(i, 1, MAXN) po2[i] = 2ll * po2[i - 1] % MOD;

    cin >> n;
    n++;
    for (int i = 1; i < n; i++) {
    	int p;
    	cin >> p;
    	adj[p].pb(i);
    }

    dfs(0);
    calc();

    return 0;
}

Measured memory_bytes: 56444