#include <bits/stdc++.h>
 
using namespace std;
#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for (int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
template <typename T> bool chkmax(T &a, const T &b) { return a < b ? a = b, true : false; }
template <typename T> bool chkmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template <typename T> T getSign(const T&a) { return (a > T(0)) - (a < T(0)); }
typedef long long LL;
typedef long double LD;
const double pi = acos(-1);
void procStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
	return x * flag;
}
void write(LL x) {
	if (x < 0) putchar('-'), x = -x;
	if (x >= 10) write(x / 10);
	putchar(x % 10 + '0');
} 

const int Maxn = 2e5 + 9, Mod = 1e9 + 7;
struct edge {
	int to, nxt;
}g[Maxn << 2];
int n, head[Maxn];

int fpm(int base, int tims) {
	int r = 1;
	for (; tims; base = 1ll * base * base % Mod, tims >>= 1) 
		if (tims & 1) r = 1ll * r * base % Mod;
	return r;
}
int inv(int x) { return fpm(x, Mod - 2); }

void add(int u, int v) {
	static int e = 0;
	g[++e] = (edge){v, head[u]}, head[u] = e;
}

int dep[Maxn], son[Maxn], top[Maxn], size[Maxn], maxDep[Maxn], sed[Maxn], power[Maxn];
int localdep[Maxn];
void Init() {
	clar(head, -1), clar(son, -1);

	n = read();
	rep (i, 1, n) {
		int u = read();
		add(i, u), add(u, i); 
	}
}

void dfs1(int u, int pa) {
	dep[u] = dep[pa] + 1; ++size[dep[u]];
	chkmax(maxDep[u], dep[u]);
	for (int i = head[u]; ~i; i = g[i].nxt) {
		int v = g[i].to;
		if (v != pa) {
			dfs1(v, u);
			if (son[u] == -1 || maxDep[v] > maxDep[u]) {
				if (~son[u]) chkmax(sed[u], maxDep[u] - dep[u]);
				son[u] = v, maxDep[u] = maxDep[v];
			} else chkmax(sed[u], maxDep[v] - dep[u]);
		}
	}
	localdep[u] = maxDep[u] - dep[u] + 1;
}

int _f[Maxn], _f1[Maxn], _depsize[Maxn], clk, dfn[Maxn];
int *f[Maxn], *f1[Maxn], *depsize[Maxn];
void dfsDp(int u, int pa) {
	dfn[u] = clk++;
	f[u] = _f + dfn[u]; f1[u] = _f1 + dfn[u]; depsize[u] = _depsize + dfn[u];
	f[u][0] = f1[u][0] = depsize[u][0] = 1;
	if (~son[u]) {
		dfsDp(son[u], u);
		rep (i, 0, sed[u]) f1[u][i] = (1ll * power[depsize[u][i]] - f[u][i] + Mod) % Mod;
	} else return ;
	
	for (int usa = head[u]; ~usa; usa = g[usa].nxt) {
		int v = g[usa].to;
		if (v != son[u] && v != pa) {
			dfsDp(v, u);

			rep (i, 0, localdep[v] - 1) {
				int tmp = (1ll * power[depsize[v][i]] - f[v][i] + Mod) % Mod;
				f[u][i + 1] = (1ll * f[u][i + 1] * tmp % Mod + 1ll * f1[u][i + 1] * f[v][i] % Mod) % Mod;
				f1[u][i + 1] = 1ll * f1[u][i + 1] * tmp % Mod;
				depsize[u][i + 1] += depsize[v][i];
			}
		}
	}
}

void Solve() {
	dfs1(0, 0);
	power[0] = 1;
	rep (i, 1, n) power[i] = power[i - 1] * 2ll % Mod;
	dfsDp(0, 0);

	LL ans = 0;
	rep (i, 0, maxDep[0] - 1) {
		ans += 1ll * fpm(2, n + 1 - depsize[0][i]) * f[0][i] % Mod;
		if (ans >= Mod) ans -= Mod;
	}
	cout << ans << endl;
}

int main() {


	Init();
	Solve();

#ifdef Qrsikno
	debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 34304