#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

using namespace std;

const long long mod = 1e9 + 7;

struct Foo {
  long long v0;
  long long v1;
  long long v2;

  Foo() : v0(0), v1(0), v2(0) {}
  Foo(long long v0, long long v1, long long v2) : v0(v0), v1(v1), v2(v2) {}
};

long long modpow(long long a, long long b) {
  long long ret = 1;
  while (b > 0) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}

int main() {
  int n;
  cin >> n;
  n++;
  vector<int> p(n, -1);
  vector<int> depth(n);
  vector< vector<int> > g(n);
  vector<int> cnt(n);
  for (int i = 1; i < n; i++) {
    cin >> p[i];
    depth[i] = depth[ p[i] ] + 1;
    g[ p[i] ].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cnt[ depth[i] ]++;
  }

  //                  depth, val
  vector< deque< pair<int,   Foo> > > dp(n);

  for (int i = n - 1; i >= 0; i--) {
    dp[i].emplace_back(depth[i], Foo(1, 1, 0));

    int mx = 1;

    for (int j : g[i]) {
      dp[j].emplace_front(depth[i], Foo(1, 0, 0));
      // merge
      if (dp[i].size() < dp[j].size()) swap(dp[i], dp[j]);

      mx = max<int>(mx, dp[j].size());

      for (int k = 0; k < dp[j].size(); k++) {
        if (dp[i][k].first != dp[j][k].first) {
          cout << "ERR" << endl;
        }
        Foo a = dp[i][k].second;
        Foo b = dp[j][k].second;

        Foo c;
        c.v0 = a.v0*b.v0 % mod;
        c.v1 = (a.v1*b.v0 + a.v0*b.v1) % mod;
        c.v2 = (a.v2*b.v0 + a.v1*b.v1 + a.v0*b.v2 + a.v1*b.v2 + a.v2*b.v1 + a.v2*b.v2) % mod;
        dp[i][k].second = c;
      }
    }

    for (int k = 0; k < mx; k++) {
      (dp[i][k].second.v0 += dp[i][k].second.v2) %= mod;
      dp[i][k].second.v2 = 0;
    }
  }

  long long ret = 0;
  for (auto p : dp[0]) {
    ret += modpow(2, n - cnt[p.first]) * p.second.v1;
    ret %= mod;
  }

  cout << ret << endl;
}
