#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
	int x = 0, fh = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

typedef long long ll;
const ll Mod = 1e9 + 7;
const int N = 2e5 + 1e3;
ll dp[N][2], ans = 0;
ll fpm(ll x, ll power) {
	ll res = 1;
	for (; power; power >>= 1, (x *= x) %= Mod)
		if (power & 1) (res *= x) %= Mod;
	return res;
}

int fa[N], n, dep[N], tot[N], pre[N], post[N];
vector<int> G[N];

int sz[N], son[N];
void Dfs_Init(int u = 1) {
	sz[u] = 1;
	for (int v : G[u]) if (v != fa[u]) {
		Dfs_Init(v); sz[u] += sz[v]; if (sz[v] > sz[son[u]]) son[u] = v;
	}
}

int top[N];
void Dfs_Part(int u = 1) {
	static int clk = 0;
	pre[u] = ++ clk;
	top[u] = son[fa[u]] == u ? top[fa[u]] : u; 
	if (son[u]) Dfs_Part(son[u]);
	for (int v : G[u]) if (v != fa[u] && v != son[u]) Dfs_Part(v);
	post[u] = clk;
}

int Lca(int x, int y) {
	for (; top[x] != top[y]; x = fa[top[x]])
		if (dep[top[x]] < dep[top[y]]) swap(x, y);
	return dep[x] < dep[y] ? x : y;
}

vector<int> In[N];

inline bool Cmp(int a, int b) { return pre[a] < pre[b]; }

namespace Virtual_Tree {

	int lis[N * 2], k;
	vector<int> E[N]; bool key[N];

	void Clear() {
		For (i, 1, k) E[lis[i]].clear(), key[lis[i]] = false;
	}

	void Build(int dep) {
		k = (int) In[dep].size();
		For (i, 1, k) key[lis[i] = In[dep][i - 1]] = true; lis[++ k] = 1;

		sort(lis + 1, lis + k + 1, Cmp);
		For (i, 1, k - 1) 
			lis[++ k] = Lca(lis[i], lis[i + 1]);
		sort(lis + 1, lis + k + 1, Cmp);
		k = unique(lis + 1, lis + k + 1) - lis - 1;

		static int sta[N], top; top = 0;
		For (i, 1, k) {
			while (top && pre[lis[i]] > post[sta[top]]) -- top;
			if (top) E[sta[top]].push_back(lis[i]); 
			sta[++ top] = lis[i];
		}
	}

	void Dp(int u) {
		for (int v : E[u]) Dp(v);
		if (key[u]) { dp[u][0] = dp[u][1] = 1; return ; }

		ll All = 1, Zero = 1;
		for (int v : E[u]) {
			(All *= (dp[v][0] + dp[v][1]) % Mod) %= Mod;
			(Zero *= dp[v][0]) %= Mod;
		}
		ll One = 0;
		for (int v : E[u])
			(One += Zero * fpm(dp[v][0], Mod - 2) % Mod * dp[v][1] % Mod) %= Mod;
		dp[u][0] = ((All - One) % Mod + Mod) % Mod; dp[u][1] = One;
	}

}

int main () {
	File();
	n = read();
	For (i, 2, n + 1) {
		fa[i] = read() + 1;
		In[dep[i] = dep[fa[i]] + 1].push_back(i);
		G[fa[i]].push_back(i);
		++ tot[dep[i]];
	}
	++ tot[0];

	Dfs_Init(); Dfs_Part();

	In[0].push_back(1);
	For (d, 0, n) {

		Virtual_Tree :: Build(d);
		dp[1][0] = dp[1][1] = 0;

		Virtual_Tree :: Dp(1);
		(ans += dp[1][1] * fpm(2, n + 1 - tot[d]) % Mod) %= Mod;

		Virtual_Tree :: Clear();
	}

	printf ("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 47488