#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7,N=200005,LN=20;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int pow1(int x,int y)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x);
      x=mult(x,x);
      y>>=1;
    }
  return ans;
}
int d[N],p[LN][N],st[N],en[N],timer;
vi adj[N],v[N],aux[N];
int dp[2][N];//0->balls,1->1 ball
int lca(int x,int y)
{
  if(d[x]<d[y]) swap(x,y);
  int diff=d[x]-d[y];
  rep(i,0,LN) if(diff&(1<<i)) x=p[i][x];
  if(x==y) return x;
  repv(i,0,LN)
    if(p[i][x]!=p[i][y])
      x=p[i][x],y=p[i][y];
  return p[0][x];
}
void dfs(int u)
{
  st[u]=++timer;
  adj[d[u]].pb(u);
  for(int v1:v[u])
    {
      d[v1]=d[u]+1;
      p[0][v1]=u;
      dfs(v1);
    }
  en[u]=timer;
}
void fun(int u)
{
  dp[0][u]=dp[1][u]=0;
  if(!sz(aux[u]))
    {
      dp[0][u]=1;//1 way for assigning 0 balls to it
      dp[1][u]=1;//1 way for assigning 1 ball to it
      return;
    }
  int prod1=1,prod2=1;
  for(int v1:aux[u])
    {
      fun(v1);
      prod1=mult(prod1,dp[0][v1]);
      prod2=mult(prod2,add(dp[0][v1],dp[1][v1]));
    }
  for(int v1:aux[u])
    {
      int inv=pow1(dp[0][v1],mod-2);
      dp[1][u]=add(dp[1][u],mult(mult(prod1,inv),dp[1][v1]));
    }
  dp[0][u]=add(prod2,-dp[1][u]);
}
int solve(int lvl)
{
  vector<ii> arr;
  rep(i,0,sz(adj[lvl]))
    {
      int v1=adj[lvl][i];
      arr.pb(mp(st[v1],v1));
      if(i)
	{
	  int u=adj[lvl][i-1];
	  int lc=lca(v1,u);
	  arr.pb(mp(st[lc],lc));
	}
    }
  sort(all(arr));
  arr.erase(unique(all(arr)),arr.end());
  rep(i,0,sz(arr))
    aux[arr[i].se].clear();
  vi ST;
  for(ii x:arr)
    {
      while(!ST.empty() && en[ST.back()]<x.fi) ST.pop_back();
      if(!ST.empty()) aux[ST.back()].pb(x.se);
      ST.pb(x.se);
    }
  fun(arr[0].se);
  return dp[1][arr[0].se];
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,x;
  cin>>n; n++;
  rep(i,2,n+1)
    {
      cin>>x; x++;
      v[x].pb(i);
    }
  dfs(1);
  rep(i,1,LN)
    rep(j,1,n+1)
    p[i][j]=p[i-1][p[i-1][j]];
  int ans=0;
  rep(i,0,n+1)
    {
      if(sz(adj[i])==0) continue;
      int tmp=solve(i);
      ans=add(ans,mult(tmp,pow1(2,n-sz(adj[i]))));
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 55680