#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

static const int N = 200010;
static const int MOD = 1000000007;
int n, d, tim, ans, nume, power[N], cnt[N], h[N], dfn[N], dep[N], id[N], up[N][20];
struct Edge {
	int v, nxt;
} e[N << 1];

bool cmpdep(int a, int b) {
	return dep[a] == dep[b] ? dfn[a] < dfn[b] : dep[a] < dep[b];
}

bool cmpdfn(int a, int b) { return dfn[a] < dfn[b]; }

void add_edge(int u, int v) {
	e[++ nume] = (Edge) { v, h[u] }, h[u] = nume;
	e[++ nume] = (Edge) { u, h[v] }, h[v] = nume;
}

void dfs(int t, int fa) {
	dfn[t] = tim ++, up[t][0] = fa;
	for (int i = h[t]; i; i = e[i].nxt)
		if (e[i].v != fa) dfs(e[i].v, t);
}

void init() {
	power[0] = 1;
	for (int i = 1; i <= n; ++ i) power[i] = (power[i - 1] << 1) % MOD;
	for (int i = 1; i <= n; ++ i) ++ cnt[dep[i]];
}

int get_lca(int x, int y) {
	if (dep[x] < dep[y]) swap(x, y);
	for (int i = 19; ~ i; -- i)
		if (dep[up[x][i]] >= dep[y]) x = up[x][i];
	if (x == y) return x;
	for (int i = 19; ~ i; -- i)
		if (up[x][i] != up[y][i]) x = up[x][i], y = up[y][i];
	return up[x][0];
}

vector <int> son[N];

void build(int l, int r) {
	vector <int> node; node.push_back(1);
	for (int i = l; i <= r; ++ i) node.push_back(id[i]);
	for (int i = node.size() - 1; i; -- i) node.push_back(get_lca(node[i - 1], node[i]));
	sort(node.begin(), node.end(), cmpdfn);
	int len = unique(node.begin(), node.end()) - node.begin();
	for (int i = 0; i < len; ++ i) son[node[i]].clear();
	stack <int> st;
	for (int i = 0; i < len; ++ i)
		if (st.empty()) st.push(node[i]);
		else {
			int lca = get_lca(node[i], st.top());
			if (lca != st.top()) do {
				int t = st.top(); st.pop();
				if (! st.empty()) son[st.top()].push_back(t); else break;
			} while (lca != st.top());
			st.push(node[i]);
		}
	do {
		int t = st.top(); st.pop();
		if (! st.empty()) son[st.top()].push_back(t); else break;
	} while (1);
}

void ex_gcd(int a, int b, int &x, int &y) {
	if (! b) { x = 1, y = 0; return; }
	ex_gcd(b, a % b, y, x), y -= a / b * x;
}

int get_inv(int t) {
	int x, y; ex_gcd(t, MOD, x, y); return (x + MOD) % MOD;
}

int zero[N], one[N];

void dp(int t) {
	if (son[t].empty()) {
		zero[t] = one[t] = 1; return;
	}
	int all = 1, size = son[t].size(); zero[t] = one[t] = 0;
	for (int i = 0; i < size; ++ i) dp(son[t][i]), all = 1ll * all * zero[son[t][i]] % MOD;
	for (int i = 0; i < size; ++ i) (one[t] += 1ll * all * get_inv(zero[son[t][i]]) % MOD * one[son[t][i]] % MOD) %= MOD;
	all = 1;
	for (int i = 0; i < size; ++ i) all = 1ll * all * (zero[son[t][i]] + one[son[t][i]]) % MOD;
	zero[t] = (all - one[t] + MOD) % MOD;
}

void count(int l, int r) {
	build(l, r), dp(1);
	(ans += 1ll * one[1] * power[n - cnt[dep[id[l]]]] % MOD) %= MOD;
}

int main() {
	cin >> n, ++ n, id[1] = dep[1] = 1;
	for (int i = 2; i <= n + 1; ++ i) {
		int fa; cin >> fa, add_edge(fa + 1, i), d = max(d, dep[id[i] = i] = dep[fa + 1] + 1);
	}
	int p = 1; dfs(1, 0), sort(id + 1, id + n + 1, cmpdep), init();
	for (int i = 1; i < 20; ++ i)
		for (int j = 1; j <= n; ++ j) up[j][i] = up[up[j][i - 1]][i - 1];
	while (p <= n) {
		int q = p + 1;
		while (q <= n && dep[id[p]] == dep[id[q]]) ++ q;
		count(p, q - 1), p = q;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 36224