#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

using namespace std;

struct HLD {
  const vector<vector<int>> &g;
  vector<int> head;
  vector<int> par;
  vector<int> sz;
  vector<int> vid;
  int sec = 0;

  HLD(const vector<vector<int>> &g) : g(g), head(g.size()), par(g.size()), sz(g.size()), vid(g.size()) {
    dfs(0, -1);
    dfs2(0, -1, 0);
  }

  void dfs(int  u, int p) {
    sz[u] = 1;
    for (int v : g[u]) if (v != p) {
      dfs(v, u);
      sz[u] += sz[v];
    }
  }

  void dfs2(int u, int p, int h) {
    head[u] = h;
    par[u] = p;
    vid[u] = sec++;
    for (int v : g[u]) if (v != p && sz[u] < sz[v] * 2) dfs2(v, u, h);
    for (int v : g[u]) if (v != p && sz[u] >= sz[v] * 2) dfs2(v, u, v);
  }

  int lca(int u, int v) {
    while (true) {
      if (vid[u] > vid[v]) swap(u, v);
      if (head[u] == head[v]) return u;
      v = par[head[v]];
    }
  }
};

struct Tree {
  const vector<vector<int>> &g;
  HLD hld;
  int sec = 0;
  vector<int> ord;

  Tree(const vector<vector<int>> &g) : g(g), hld(g), ord(g.size()) {
    dfs(0, -1);
  }

  void dfs(int u, int p) {
    ord[u] = sec++;
    for (int v : g[u]) if (v != p) {
      dfs(v, u);
    }
  }

  // Return the parents of given vertices. (vertex id, parent id)
  vector<pair<int, int>> contract(vector<int> vs) {
    priority_queue<pair<int, int>> q;
    set<int> st;
    for (int v : vs) {
      q.emplace(ord[v], v);
      st.insert(v);
    }

    vector<pair<int, int>> ret;
    while (q.size() >= 2) {
      int u = q.top().second; q.pop();
      int v = q.top().second;
      int w = hld.lca(u, v);
      ret.emplace_back(u, w);
      if (!st.count(w)) {
        st.insert(w);
        q.emplace(ord[w], w); 
      }
    }

    ret.emplace_back(q.top().second, -1);
    return ret;
  }
};

const int mod = 1e9 + 7;

struct Modint {
  int n;
  Modint(int n = 0) : n(n) {}
};

Modint operator+(Modint a, Modint b) { return Modint((a.n += b.n) >= mod ? a.n - mod : a.n); }
Modint operator-(Modint a, Modint b) { return Modint((a.n -= b.n) < 0 ? a.n + mod : a.n); }
Modint operator*(Modint a, Modint b) { return Modint(1LL * a.n * b.n % mod); }
Modint &operator+=(Modint &a, Modint b) { return a = a + b; }
Modint &operator-=(Modint &a, Modint b) { return a = a - b; }
Modint &operator*=(Modint &a, Modint b) { return a = a * b; }

Modint modpow(Modint a, int b) {
  Modint ret = 1;
  while (b > 0) {
    if (b & 1) ret *= a;
    a *= a;
    b >>= 1;
  }
  return ret;
}

Modint modinv(Modint a) {
  return modpow(a, mod - 2);
}

int main() {
  int n;
  cin >> n;
  n++;

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

  Tree tree(g);

  vector<vector<int>> vs(n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    vs[ depth[i] ].push_back(i);
    mx = max(mx, depth[i]);
  }

  Modint ans = 0;
  vector<Modint> dp0(n);
  vector<Modint> dp1(n);
  vector<vector<int>> gg(n);
  for (int k = 0; k <= mx; k++) {
    auto ps = tree.contract(vs[k]);
    int last;
    for (auto p : ps) {
      last = p.first;
      if (p.second != -1) {
        gg[p.second].push_back(p.first);
      }
      int i = p.first;
      if (depth[i] == k) {
        dp0[i] = 1;
        dp1[i] = 1;
        continue;
      }
      Modint all_zero = 1;
      Modint all = 1;
      for (int j : gg[i]) {
        all_zero *= dp0[j];
        all *= (dp0[j] + dp1[j]);
      }
      Modint one = 0;
      for (int j : gg[i]) {
        one += all_zero * modinv(dp0[j]) * dp1[j];
      }

      dp0[i] = all - one;
      dp1[i] = one;
    }
    ans += dp1[last] * modpow(2, n - vs[k].size());

    for (auto p : ps) {
      dp0[p.first] = 0;
      dp1[p.first] = 0;
      gg[p.first].clear();
    }
  }

  cout << ans.n << endl;
}


Measured memory_bytes: 77568