#include <bits/stdc++.h>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
using namespace std;
 
const int mod = 1e9 + 7;
int n, m, p[200010],id[200010],ans;
vector <int> son[200010],f[200010],g[200010],s,tim;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int qpow(int a, int b)
{
	int x = a;  
	a = 1;
	while (b)
	{
		if (b & 1) a = 1LL * a * x % mod;
		x = 1LL * x * x % mod, b >>= 1;
	}
	return a;
}
 
void dfs(int x)
{
	int hs = -1, ID;
	for (auto y : son[x])
	{
		dfs(y);
		if ((hs < 0) || (f[id[y]].size() > f[id[hs]].size())) hs = y;
	}
	if (hs < 0)
	{
		id[x] = ++ m;
		f[m].push_back(1);
		g[m].push_back(1);
		return;
	}
	ID = id[x] = id[hs];
	for (auto y : son[x])
		if (y != hs)
		{
			int d = f[ID].size() - f[id[y]].size();
			for (int i = 0; i < (int)f[id[y]].size(); i ++)
			{
				if (tim[i + d] != x) s[i + d] = (qpow(2, g[ID][i + d]) + mod - f[ID][i + d]) % mod, tim[i + d] = x;
				f[ID][i + d] = 1LL * f[ID][i + d] * (qpow(2, g[id[y]][i]) + mod - f[id[y]][i]) % mod;
				f[ID][i + d] = (f[ID][i + d] + 1LL * s[i + d] * f[id[y]][i]) % mod;
				g[ID][i + d] += g[id[y]][i];
				s[i + d] = 1LL * s[i + d] * (qpow(2, g[id[y]][i]) + mod - f[id[y]][i]) % mod;
			}
		}
	f[id[x]].push_back(1);
	g[id[x]].push_back(1);
}
 
 
int main()
{
	scanf("%d", &n);
	s.resize(n + 1);
	tim.resize(n + 1, -1);
	rep(i, 1, n)
		p[i] = read(),
		son[p[i]].push_back(i);
	dfs(0);
	for (int i = 0; i < f[id[0]].size(); i ++)
		ans = (ans + 1LL * f[id[0]][i] * qpow(2, n + 1 - g[id[0]][i])) % mod;
	printf("%d", ans);
	return 0;
}
