#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template <typename T>
T inverse(T a, T m) {
  T u = 0, v = 1;
  while (a != 0) {
    T t = m / a;
    m -= t * a; std::swap(a, m);
    u -= t * v; std::swap(u, v);
  }
  assert(m == 1);
  return u;
}
template <typename T>
class modular {
  private:
    int value;
  public:
    constexpr modular() = default;
    constexpr modular(const modular&) = default;
    constexpr modular(modular&&) = default;
    modular& operator=(const modular&) = default;
    modular& operator=(modular&&) = default;

    template <typename U>
    modular (const U& x) {value = normalize(x);}

    template <typename U>
    static auto normalize(const U& x) {
      int v = static_cast<int>(-mod() <= x && x < mod() ? x : x % mod());
      if (v < 0) v += mod();
      return v;
    }

    auto const& operator()() const { return value; }
    template <typename U>
    explicit operator U() const { return static_cast<U>(value); }
    constexpr static auto mod() { return T::value; }

    auto& operator+=(const modular& other) {
      if ((value += other.value) >= mod()) value -= mod();
      return *this;
    }
    auto& operator-=(const modular& other) {
      if ((value -= other.value) < 0) value += mod();
      return *this;
    }
    template <typename U>
    auto& operator+=(const U& other) {return *this += modular(other); }
    template <typename U>
    auto& operator-=(const U& other) {return *this -= modular(other); }
    auto operator-() const { return modular(-value); }
    auto& operator++() {return *this += 1;}
    auto& operator--() {return *this -= 1;}
    auto  operator++(int) {modular result(*this); operator++(); return result;}
    auto  operator--(int) {modular result(*this); operator--(); return result;}

    template <typename U = T>
    auto& operator*=(const modular& rhs) {
      value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value));
      return *this;
    }
    auto& operator/=(const modular& other) {
      return *this *= modular(inverse(other.value, mod()));
    }
};
template <typename T> struct is_modular : std::false_type {};
template <typename T> struct is_modular <modular<T>> : std::true_type{};
template <typename T> constexpr bool is_modular_v = is_modular<T>::value;

template <typename T> bool operator==(const modular<T>& lhs, const modular<T>& rhs) { return lhs() == rhs(); }
template <typename T, typename U> bool operator==(const modular<T>& lhs, U rhs) { return lhs == modular<T>(rhs); }
template <typename T, typename U> bool operator==(U lhs, const modular<T>& rhs) { return modular<T>(lhs) == rhs; }

template <typename T> bool operator!=(const modular<T>& lhs, const modular<T>& rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(const modular<T>& lhs, U rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(U lhs, const modular<T>& rhs) { return !(lhs == rhs); }

template <typename T> modular<T> operator+(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(const modular<T>& lhs, U rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(U lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }

template <typename T> modular<T> operator-(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(const modular<T>& lhs, U rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(U lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }

template <typename T> modular<T> operator*(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(const modular<T>& lhs, U rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(U lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }

template <typename T> modular<T> operator/(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(const modular<T>& lhs, U rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(U lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }

template<typename T, typename U>
modular<T> power (const modular<T>& a, U b) {
  assert(b >= 0);
  modular<T> x = a, ret = 1;
  for (; b > 0; b /= 2) {
    if (b % 2 == 1) ret *= x;
    x *= x;
  }
  return ret;
}

template <typename T>
std::string to_string(const modular<T>& a) {
  return std::to_string(a());
}
template <typename T>
auto operator<<(std::ostream& os, const T& a)
  -> std::enable_if_t<is_modular_v<T>, std::ostream&>{
    return os << a();
  }
template <typename T>
auto operator>>(std::istream& is, T& a)
  -> std::enable_if_t<is_modular_v<T>, std::istream&> {
  long long x; is >> x;
  a = T(x);
  return is;
}

// using mod_type = int;

// struct variable_mod { static mod_type value; };
// mod_type variable_mod::value;
// mod_type& mod = variable_mod::value;
// using mint = modular< variable_mod >;

constexpr int mod = 1'000'000'007;
using mint = modular<std::integral_constant<std::decay_t<decltype(mod)>, mod>>;

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

struct rational {int n, d;};
auto to_string(rational r) -> std::string {
  return r.d == 1
    ? std::to_string(r.n)
    : std::to_string(r.n) + "/" + std::to_string(r.d);
}
std::ostream& operator << (std::ostream& os, rational r)
  { return os << to_string(r); }
auto guess (mint k) -> rational {
  auto const dmax = 1000;
  auto const nmax = 1000;
  for (auto d = 1; d < dmax; d++) {
    auto n = int(k * mint(d));
    if (n < nmax) return {n, d};
    n = mod - n;
    if (n < nmax) return {-n, d};
  }
  return {-1, 0};
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  int N = n + 1;
  std::vector<std::vector<int>> graph(N);
  rep(i,1,N) {
    int p; std::cin >> p;
    // std::cout << "\"" << p << "\"->" << i << "\"" << std::endl;
    graph.at(p).emplace_back(i);
  }
  debug(graph);

  int rt = 0;
  auto ht = [&] {
    std::vector<int> ht(N,1);
    auto dfs = [&] (auto&& dfs, int x, auto&& ht) -> void {
      auto&& child = graph.at(x);
      if (child.empty()) return;
      int & h = ht.at(x);
      for (int & y : child) {
        dfs(dfs,y,ht);
        cmx(h, ht.at(y)+1);
      }
      std::sort(all(child), [&ht](int u, int v){ return ht.at(u) > ht.at(v); });
    };
    dfs(dfs,rt,ht);
    return ht;
  }();
  debug(ht,graph);

  using vec = std::vector<mint>;
  mint half = mint{1}/2;
  auto dp = [&] {
    auto dfs = [&] (auto&& dfs, int x) {
      auto&& child = graph.at(x);
      if (child.empty()) { return vec{half}; }

      int head = child.front();
      vec ans = dfs(dfs, head);
      assert((int)ans.size()==ht.at(head));
      ans.emplace_back(half);

      if (2u <= child.size()) {
        int head1 = child.at(1);
        int len = ht.at(head1);
        vec a(len,0), b(len,1);
        rep(i,0,len) {
          int j = i + ht.at(head) - ht.at(head1);
          assert(0 <= j && j < (int)ans.size());
          mint p = ans.at(j);
          a.at(i) += p / (1 - p);
          b.at(i) *= 1 - p;
        }
        for (int y : child) {
          if (y==head) continue;
          auto v = dfs(dfs,y);
          assert((int)v.size()==ht.at(y));
          rep(i,0,ht.at(y)) {
            mint p = v.at(i);
            int j = i + ht.at(head1) - ht.at(y);
            assert(0 <= j && j < len);
            a.at(j) += p / (1 - p);
            b.at(j) *= 1 - p;
          }
        }
        rep(i,0,len) {
          int j = i + ht.at(head) - ht.at(head1);
          assert(0 <= j && j < (int)ans.size());
          mint p = a.at(i) * b.at(i);
          ans.at(j) = p;
        }
      }

      #ifndef STOPIT
        std::cerr << "[dp] " << x <<":";
        for (mint x : ans) {
          std::cerr << " " << guess(x);
        }
        std::cerr<<std::endl;
      #endif
      return ans;
    };
    auto dp = dfs(dfs,rt);
    return dp;
  }();

  debug(dp);
  mint ans = 0;
  for (mint x : dp) {
    ans += x;
  }
  ans *= power(mint{2}, N);
  std::cout << ans << std::endl;
  return 0;
}

/*
各頂点について、各時刻にビー玉のある確率を計算します。
マージテクを使いたいので、高さ最大の個が 0 番目に来るように予め並び替えます。
このままだと親の配列に転用するときに添字をずらさなければいけません。
そこで DP 配列の時刻キーを逆順にして、（部分木の高さ）−（時刻）がキーになるようにします。
すると、1 番目以降の子の関与するところのみを再計算すればよいです。
*/

Measured memory_bytes: 72572