// default code for competitive programming
// ver 3.1415 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, e) for( int i = 0 ; i < (e) ; i++ )
#define ITER(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#define PB push_back
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

#ifdef AKAI
#define debug( ... ) fprintf( stderr , __VA_ARGS__ )
#else
#define debug( ... )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = 1e-8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

int _R( int& x ) { return scanf( "%d" , &x ); }
int _R( ll& x ) { return scanf( "%" PRId64 , &x ); }
int _R( double& x ) { return scanf( "%lf" , &x ); }
int _R( char* s ) { return scanf( "%s" , s ); }

int R() { return 0; }

  template< typename T1 , typename... T2 >
int R( T1& x , T2&... tail )
{
  int tmp = _R( x );
  return tmp + R( tail... );
}

  template< typename Iter , typename F >
inline void out( Iter s , Iter e , F of )
{
  bool flag = 0;
  for( Iter it = s ; it != e ; it++ )
  {
    if( flag ) printf( " " );
    else flag = 1;
    of( *it );
  }
  puts( "" );
}

// }}}
// start ~~QAQ~~

const int N = 2e5+10;
const int LG = 20;
const int MOD = 1e9+7;

inline int add(int a, int b) {
  a += b;
  return a >= MOD ? a - MOD: a;
}
inline ll mul(ll a, int b) {
  a *= b;
  return a >= MOD ? a % MOD: a;
}
inline int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + MOD: a;
}

int n;
int p[N], dep[N], ts[N], stamp;
vector<int> d[N], g[N];
int two[N];
int mom[LG][N];

void dfs(int u) {
  ts[u] = ++stamp;
  mom[0][u] = p[u];
  for (int v: g[u]) dfs(v);
}

inline int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  int jmp = dep[v] - dep[u];
  FOR(k, LG) if ((jmp>>k)&1) v = mom[k][v];
  if (u == v) return u;
  REPD(k, LG-1, 0) if (mom[k][u] != mom[k][v])
    tie(u, v) = tie(mom[k][u], mom[k][v]);
  return mom[0][u];
}

int tp[N];
int dp[N][2];
vector<int> ch[N];
int tcd;

void dfs2(int u) {
  if (dep[u] == tcd) {
    dp[u][0] = 1;
    dp[u][1] = 1;
    return;
  }
  dp[u][0] = 0;
  dp[u][1] = 0;
  int all = 1;
  vector<int> tmp;
  for (int v: ch[u]) {
    dfs2(v);
    all = mul(all, add(dp[v][0], dp[v][1]));
    tmp.push_back(dp[v][0]);
  }
  REPD(i, SZ(tmp)-2, 0) {
    tmp[i] = mul(tmp[i], tmp[i+1]);
  }
  int cur0 = 1, i = 0;
  int res = 0;
  for (int v: ch[u]) {
    int rgt = 1;
    if (i + 1 < SZ(tmp)) rgt = tmp[i+1];
    res = add(res, mul(cur0, mul(dp[v][1], rgt)));
    ++i;
    cur0 = mul(cur0, dp[v][0]);
  }
  dp[u][1] = res;
  dp[u][0] = sub(all, res);
}

int f(int cd) {
  tcd = cd;
  vector<int> &levs = d[cd];
  sort(ALL(levs), [&](int a, int b) {return ts[a] < ts[b];});
  vector<int> stk{0};
  set<int> vs{0};
  int prv = 0;
  for (int u: levs) {
    vs.insert(u);
    int anc = 0;
    if (prv != 0) anc = lca(u, prv);
    vs.insert(anc);
    while (SZ(stk) and dep[stk.back()] > dep[anc]) {
      if (dep[tp[stk.back()]] < dep[anc]) {
        tp[stk.back()] = anc;
      }
      stk.pop_back();
    }
    if (SZ(stk) and dep[stk.back()] < dep[anc]) {
      tp[anc] = stk.back();
      stk.push_back(anc);
    }
    tp[u] = stk.back();
    stk.push_back(u);
    prv = u;
  }
  for (int u: vs) {
    if (u) ch[tp[u]].push_back(u);
  }
  dfs2(0);
 
  for (int u: vs) {
    tp[u] = 0;
    ch[u].clear();
  }
  return dp[0][1];
}

int main() {
  R(n);
  REP(i, 1, n) {
    R(p[i]);
    dep[i] = dep[p[i]] + 1;
    d[dep[i]].push_back(i);
    g[p[i]].push_back(i);
  }
  dfs(0);
  FOR(k, LG-1) REP(i, 1, n)
    mom[k+1][i] = mom[k][mom[k][i]];

  two[0] = 1;
  REP(i, 1, n+1) two[i] = add(two[i-1], two[i-1]);
  int ans = two[n];
  REP(i, 1, n+1) if (SZ(d[i])) {
    int rst = n+1 - SZ(d[i]);
    ans = add(ans, mul(f(i), two[rst]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 54144