use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn pow_mod(base: i64, power: i64, modulo: i64) -> i64 {
    let mut base = base;
    let mut power = power;
    let mut ans = 1;
    while power > 0 {
        if power & 1 == 1 { ans = ans * base % modulo; }
        power >>= 1;
        base = base * base % modulo;
    }
    ans
}

#[allow(dead_code)]
fn inv_mod(a: i64, modulo: i64) -> i64 {
    pow_mod(a, modulo - 2, modulo)
}

type Weight = i32;
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq)]
struct Edge {
    index: usize,
    src: usize,
    dest: usize,
    weight: Weight,
}
#[allow(dead_code)]
impl Edge {
    fn new(index: usize, src: usize, dest: usize, weight: Weight) -> Edge {
        Edge {
            index: index,
            src: src,
            dest: dest,
            weight: weight,
        }
    }
}
impl std::cmp::Ord for Edge {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        (self.weight, self.src, self.dest).cmp(&(other.weight, other.src, other.dest))
    }
}
impl std::cmp::PartialOrd for Edge {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
type Edges = Vec<Edge>;
type Graph = Vec<Edges>;
#[allow(dead_code)]
fn graph_new(n: usize) -> Graph {
    vec![vec![]; n]
}
#[allow(dead_code)]
fn add_bi_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    graph[dest].push(Edge::new(*index, dest, src, weight));
    *index += 1;
}
#[allow(dead_code)]
fn add_uni_edge(graph: &mut Graph, index: &mut usize, src: usize, dest: usize, weight: Weight) {
    graph[src].push(Edge::new(*index, src, dest, weight));
    *index += 1;
}


const MOD: i64 = 1e+9 as i64 + 7;
struct Solver {
    n: usize,
    g: Graph,
}

impl Solver {
    fn new() -> Solver {
        let n: usize = read::<usize>() + 1;
        let mut g = graph_new(n);
        let mut e = 0;
        for i in 0..n-1 {
            let p: usize = read();
            add_bi_edge(&mut g, &mut e, p, i + 1, 1);
        }
        Solver {
            n: n,
            g: g,
        }
    }
    fn dfs(&self, from: usize, parent: usize) -> VecDeque<(i64, i64, i64)> {
        let mut deq = VecDeque::new();
        let mut twos = vec![];
        for edge in self.g[from].iter() {
            if edge.dest == parent { continue; }
            let mut ndeq = self.dfs(edge.dest, from);
            let mut swapped = false;
            if deq.len() < ndeq.len() {
                std::mem::swap(&mut deq, &mut ndeq);
                swapped = true;
            }
            if twos.len() < ndeq.len() {
                twos.resize(deq.len(), 0);
            }
            for i in 0..ndeq.len() {
                let zero = deq[i].0 * ndeq[i].0 % MOD;
                let one = (deq[i].0 * ndeq[i].1 + deq[i].1 * ndeq[i].0) % MOD;
                twos[i] = (deq[i].1 * ndeq[i].1 % MOD + twos[i] * 
                    if !swapped { ndeq[i].0 + ndeq[i].1 } else { deq[i].0 + deq[i].1 }
                % MOD ) % MOD;
                let cnt = deq[i].2 + ndeq[i].2;
                deq[i] = (zero, one, cnt);
            }
        }
        for i in 0..twos.len() {
            deq[i].0 = (deq[i].0 + twos[i]) % MOD;
        }
        deq.push_front((1, 1, 1));
        deq
    }
    fn solve(&mut self) {
        let mut pow2 = vec![1; self.n + 1];
        for i in 0..self.n {
            pow2[i + 1] = pow2[i] * 2 % MOD;
        }
        let deq = self.dfs(0, 0);
        let mut ans = 0;
        for tuple in deq.iter() {
            let cnt = tuple.1;
            let amp = pow2[self.n - tuple.2 as usize];
            ans = (ans + cnt * amp) % MOD;
        }
        println!("{}", ans);
    }
}

fn main() {
    let mut solver = Solver::new();
    solver.solve();
}

Measured memory_bytes: 141692