#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = INT_MAX;
const LL INF = LLONG_MAX;

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

template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + (ch - '0');
	return sum * fl;
}

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int N, LG;
int pw[maxn];

inline void add (int &x, int y) { x = x + y >= mod ? x + y - mod : x + y; }

namespace Tree
{
	int c;
	int he[maxn], ne[maxn], to[maxn];

	inline void add_edge (int x, int y) { ne[++c] = he[x]; he[x] = c; to[c] = y; }

	int dep[maxn], fa[20][maxn], siz[maxn], dfn[maxn];

	void init (int p, int f)
	{
		static int tim = 0;
		dep[p] = dep[f] + 1; fa[0][p] = f; siz[p] = 1; dfn[p] = ++tim;
		for (int i = 1; i <= LG; ++i) fa[i][p] = fa[i - 1][fa[i - 1][p]];
		for (int i = he[p]; i; i = ne[i]) init (to[i], p), siz[p] += siz[to[i]];
	}

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

inline bool cmp_dfn (int x, int y) { return Tree :: dfn[x] < Tree :: dfn[y]; }

inline bool chk (int f, int x) 
{
	using namespace Tree;
	return dfn[f] <= dfn[x] && dfn[f] + siz[f] - 1 >= dfn[x]; 
}

namespace Imagine
{
	int c;
	int he[maxn], ne[maxn], to[maxn];

	inline void add_edge (int x, int y) { ne[++c] = he[x]; he[x] = c; to[c] = y; }

	int siz[maxn], dp[maxn];

	void dfs (int p)
	{
		if (he[p] == 0) { dp[p] = siz[p] = 1; return; }
		dp[p] = siz[p] = 0;

		static int pre[maxn], suf[maxn];
		for (int i = he[p]; i; i = ne[i]) dfs (to[i]), siz[p] += siz[to[i]];

		int cnt = 0; 
		for (int i = he[p]; i; i = ne[i]) pre[++cnt] = (pw[siz[to[i]]] + mod - dp[to[i]]) % mod;
		for (int i = cnt; i >= 1; --i) suf[i] = i == cnt ? pre[i] : (LL)suf[i + 1] * pre[i] % mod;
		for (int i = 1; i <= cnt; ++i) pre[i] = i == 1 ? pre[i] : (LL)pre[i - 1] * pre[i] % mod;

		pre[0] = suf[cnt + 1] = 1;
		for (int i = he[p], j = 1; i; i = ne[i], ++j) add (dp[p], (LL)pre[j - 1] * suf[j + 1] % mod * dp[to[i]] % mod);
	}

	inline void build_tree (vector <int>& vec)
	{
		static int tmp[maxn << 1]; int cnt = 0;

		for (auto o: vec) tmp[++cnt] = o;
		sort (tmp + 1, tmp + cnt + 1, cmp_dfn);

		tmp[++cnt] = 1;
		for (int i = cnt; i >= 2; --i) tmp[++cnt] = Tree :: get_lca (tmp[i], tmp[i - 1]);
		sort (tmp + 1, tmp + cnt + 1, cmp_dfn);
		cnt = unique (tmp + 1, tmp + cnt + 1) - tmp - 1;

		c = 0;
		for (int i = 1; i <= cnt; ++i) he[tmp[i]] = 0;

		for (int i = 1, top = 0; i <= cnt; ++i)
		{
			while (top && !chk (tmp[top], tmp[i])) --top;
			if (top) add_edge (tmp[top], tmp[i]);
			tmp[++top] = tmp[i];
		}
	}
}

vector <int> vec[maxn];

inline void solve ()
{
	Tree :: init (1, 0);
	pw[0] = 1;
	for (int i = 1; i <= N; ++i) pw[i] = 2ll * pw[i - 1] % mod;

	int Ans = 0;

	for (int i = 1; i <= N; ++i) vec[Tree :: dep[i]].pb (i);
	for (int i = 1; i <= N; ++i) if (vec[i].size ())
	{
		Imagine :: build_tree (vec[i]);
		Imagine :: dfs (1);

		add (Ans, (LL)pw[N - vec[i].size ()] * Imagine :: dp[1] % mod);
	}

	printf ("%d\n", Ans);
}

inline void input ()
{
	N = read<int>() + 1; LG = log2 (N); 
	for (int i = 2; i <= N; ++i) Tree :: add_edge (read<int>() + 1, i);
}

int main ()
{


	input ();
    solve ();

    return 0;
}


Measured memory_bytes: 45440