#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { ++i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr range(itr l_, itr r_) noexcept : l(l_), r(std::max(l_, r_)) { }
  constexpr iterator begin() const noexcept { return l; }
  constexpr iterator end() const noexcept { return r; }
};

struct revrange {
  using itr = int64_t;
  struct iterator {
    itr i;
    constexpr iterator(itr i_) noexcept : i(i_) { }
    constexpr void operator ++ () noexcept { --i; }
    constexpr itr operator * () const noexcept { return i; }
    constexpr bool operator != (iterator x) const noexcept { return i != x.i; }
  };
  const iterator l, r;
  constexpr revrange(itr l_, itr r_) noexcept : l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr iterator begin() const noexcept { return r; }
  constexpr iterator end() const noexcept { return l; }
};

#line 2 "/Users/kodamankod/Desktop/Programming/Library/algebraic/modular.cpp"

#include <cstdint>
#line 5 "/Users/kodamankod/Desktop/Programming/Library/algebraic/modular.cpp"

template <uint32_t Modulus>
class modular {
public:
  using value_type = uint32_t;
  using max_type = uint64_t;

  static constexpr value_type mod = Modulus;
  static constexpr value_type get_mod() noexcept { return mod; }
  static_assert(mod >= 2, "invalid mod :: smaller than 2");
  static_assert(mod < (value_type(1) << 31), "invalid mod :: over 2^31");

  template <class T>
  static constexpr value_type normalize(T value_) noexcept {
    if (value_ < 0) {
      value_ = -value_;
      value_ %= mod;
      if (value_ == 0) return 0;
      return mod - value_;
    }
    return value_ % mod;
  }

private:
  value_type value;

public:
  constexpr modular() noexcept : value(0) { }
  template <class T>
  explicit constexpr modular(T value_) noexcept : value(normalize(value_)) { }
  template <class T>
  explicit constexpr operator T() const noexcept { return static_cast<T>(value); }

  constexpr value_type get() const noexcept { return value; }
  constexpr modular operator - () const noexcept { return modular(mod - value); }
  constexpr modular operator ~ () const noexcept { return inverse(); }

  constexpr value_type &extract() noexcept { return value; }
  constexpr modular inverse() const noexcept { return power(mod - 2); }
  constexpr modular power(max_type exp) const noexcept {
    modular res(1), mult(*this);
    while (exp > 0) {
      if (exp & 1) res *= mult;
      mult *= mult;
      exp >>= 1;
    }
    return res;
  }

  constexpr modular operator + (const modular &rhs) const noexcept { return modular(*this) += rhs; }
  constexpr modular& operator += (const modular &rhs) noexcept { 
    if ((value += rhs.value) >= mod) value -= mod; 
    return *this; 
  }

  constexpr modular operator - (const modular &rhs) const noexcept { return modular(*this) -= rhs; }
  constexpr modular& operator -= (const modular &rhs) noexcept { 
    if ((value += mod - rhs.value) >= mod) value -= mod; 
    return *this; 
  }

  constexpr modular operator * (const modular &rhs) const noexcept { return modular(*this) *= rhs; }
  constexpr modular& operator *= (const modular &rhs) noexcept { 
    value = (max_type) value * rhs.value % mod;
    return *this;
  }

  constexpr modular operator / (const modular &rhs) const noexcept { return modular(*this) /= rhs; }
  constexpr modular& operator /= (const modular &rhs) noexcept { return (*this) *= rhs.inverse(); }

  constexpr bool zero() const noexcept { return value == 0; }
  constexpr bool operator == (const modular &rhs) const noexcept { return value == rhs.value; }
  constexpr bool operator != (const modular &rhs) const noexcept { return value != rhs.value; }
  friend std::ostream& operator << (std::ostream &stream, const modular &rhs) {
    return stream << rhs.value;
  }

};

/**
 * @title Modint
 */
#line 2 "/Users/kodamankod/Desktop/Programming/Library/other/fix_point.cpp"

#line 4 "/Users/kodamankod/Desktop/Programming/Library/other/fix_point.cpp"

template <class Func>
struct fix_point: private Func {
  explicit constexpr fix_point(Func &&func): Func(std::forward<Func>(func)) { }
  template <class... Args>
  constexpr decltype(auto) operator () (Args &&... args) const {
    return Func::operator()(*this, std::forward<Args>(args)...);
  }
};

template <class Func>
constexpr decltype(auto) make_fix_point(Func &&func) {
  return fix_point<Func>(std::forward<Func>(func));
}

/**
 * @title Lambda Recursion
 */
#line 57 "main.cpp"

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

using m32 = modular<1000000007>;

int main() {
  size_t N;
  std::cin >> N;
  N += 1;
  std::vector<std::vector<i32>> base_children(N);
  for (auto i: range(1, N)) {
    i32 p;
    std::cin >> p;
    base_children[p].push_back(i);
  }
  i32 root = 0, leaves = 1;
  std::vector<std::vector<i32>> children(N);
  std::vector<std::pair<m32, m32>> dp(N);
  auto calc = fix_point([&](auto calc, i32 u) -> void {
    if (children[u].empty()) {
      dp[u] = { m32(1), m32(1) };
      return;
    }
    size_t size = children[u].size();
    m32 accum(1);
    for (auto v: children[u]) {
      calc(v);
      accum *= dp[v].first + dp[v].second;
    }
    std::vector<m32> pref(size + 1), suff(size + 1);
    pref.front() = suff.front() = m32(1);
    for (auto i: range(0, size)) {
      pref[i + 1] = pref[i] * dp[children[u][i]].second;
      suff[i + 1] = suff[i] * dp[children[u][size - i - 1]].second;
    }
    dp[u] = { m32(0), m32(0) };
    for (auto i: range(0, size)) {
      dp[u].first += dp[children[u][i]].first * pref[i] * suff[size - i - 1];
    }
    dp[u].second = accum - dp[u].first;
  });
  auto rebuild = fix_point([&](auto rebuild, i32 u) -> i32 {
    std::vector<i32> new_children;
    if (children[u].empty()) {
      new_children = base_children[u];
      leaves += base_children[u].size();
      leaves -= 1;
    }
    else {
      for (auto v: children[u]) {
        auto tmp = rebuild(v);
        if (tmp != -1) {
          new_children.push_back(tmp);
        }
      }
    }
    size_t size = new_children.size();
    if (size == 0) {
      return -1;
    }
    if (size == 1) {
      return new_children.front();
    }
    children[u] = std::move(new_children);
    return u;
  });
  m32 ans;
  while (root != -1) {
    calc(root);
    ans += dp[root].first * m32(2).power(N - leaves);
    root = rebuild(root);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 20424