#include <map>
#include <set>
#include <unordered_set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <climits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>
#include <atomic>
#include <thread>

using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define drep(i,n) int i = 0;for(;i<(int)(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(int)(e);++i)
#define DFOR(i,s,e) int i = s;for(;i<=(int)(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(int)(e);--i)
#define DFORR(i,s,e) int i = s;for(;i>=(int)(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ft first
#define sd second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> bool Max(T1& a, T2 b) { return a<b ? a = b, 1 : 0; }
template<typename T1, typename T2> bool Min(T1& a, T2 b) { return a>b ? a = b, 1 : 0; }

template<int MOD>
struct ModInt {
  unsigned x;
  ModInt() : x(0) { }
  ModInt(signed sig) : x(sig) {  }
  ModInt(signed long long sig) : x(sig%MOD) { }
  int get() const { return (int)x; }
  ModInt pow(unsigned p) { ModInt res = 1, a = *this; while (p) { if (p & 1) res *= a; a *= a; p >>= 1; } return res; }

  ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
  ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
  ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
  ModInt &operator/=(ModInt that) { return (*this) *= that.pow(MOD - 2); }

  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  bool operator<(ModInt that) const { return x < that.x; }
  friend ostream& operator<<(ostream &os, ModInt a) { os << a.x; return os; }
};
typedef ModInt<1000000007> mint;

const int N = 200002, inf=1e9;
int dep[N], mxdep;
vector<int> g[N];
mint p2[N];
struct node { mint x, y; int c; };
vector<node> a[N];

int combine(vector<node>&& a, vector<node>&& b) {
  if (b.size() > a.size())swap(a, b);
  int i = a.size() - 1, j = b.size() - 1;
  while (j >= 0) {
    a[i].c += b[j].c;
    a[i].x = a[i].x * b[j].y + a[i].y * b[j].x;
    a[i].y *= b[j].y;
    i--;
    j--;
  }
  return b.size();
}

void dfs(int i) {
  int mx = 0;
  fore(e, g[i]) {
    dfs(e);
    Max(mx, combine(move(a[i]), move(a[e])));
  }
  FORR(j, a[i].size() - 1, a[i].size() - mx) {
    a[i][j].y = p2[a[i][j].c] - a[i][j].x;
  }
  a[i].push_back({ 1, 1, 1 });
}

void solve() {
  p2[0] = 1;
  FOR(i, 1, N - 1)p2[i] = p2[i - 1] * 2;
  int n, p;
  cin >> n;
  FOR(i, 1, n) {
    cin >> p;
    g[p].push_back(i);
  }
  dfs(0);
  mint ans = 0;
  fore(e, a[0]) {
    ans += p2[n+1-e.c] * e.x;
  }
  cout << ans << ln;
  
}


void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  int TC = 1;
#if 0
  cin >> TC; cin.get();
#endif
  FOR(TI, 1, TC) {
    //cout << "Case #" << TI << ": ";
    solve();
  }


  return 0;
}

Measured memory_bytes: 33012