#include <iostream>
#include <vector>
#include <deque>
#include <functional>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
using Graph = std::vector<std::vector<Edge<Cost>>>;

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

struct Pat {
    mint zero, one;
    int sz;

    Pat(mint zero, mint one, int sz)
        : zero(zero), one(one), sz(sz) {}

    Pat operator*(const Pat& p) const {
        mint nzero = zero * p.zero;
        mint none = zero * p.one + one * p.zero;
        return Pat(nzero, none, sz + p.sz);
    }
};

void solve() {
    int n;
    std::cin >> n;

    Graph<> graph(n + 1);
    for (int v = 1; v <= n; ++v) {
        int p;
        std::cin >> p;
        graph[p].emplace_back(p, v);
    }

    std::function<std::deque<Pat>(int)>
        dfs = [&](int v) -> std::deque<Pat> {
        std::deque<Pat> ret;

        int sz = 0;
        for (auto e : graph[v]) {
            auto que = dfs(e.dst);

            if (ret.size() < que.size()) std::swap(ret, que);
            sz = std::max(sz, (int)que.size());

            for (int i = 0; i < (int)que.size(); ++i) {
                ret[i] = ret[i] * que[i];
            }
        }

        for (int i = 0; i < sz; ++i) {
            auto& p = ret[i];
            p.zero = mint(2).pow(p.sz) - p.one;
        }
        ret.emplace_front(1, 1, 1);

        return ret;
    };

    auto que = dfs(0);
    mint ans = 0;
    for (auto p : que) {
        ans += p.one * mint(2).pow(n + 1 - p.sz);
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}


Measured memory_bytes: 170624