Snuke has a rooted tree with N+1 vertices.
The vertices are numbered 0 through N, and Vertex 0 is the root of the tree.
The parent of Vertex i (1 \leq i \leq N) is Vertex p_i.
Besides this tree, Snuke also has an box which is initially empty and many marbles, and playing with them.
The play begins with placing one marble on some of the vertices, then proceeds as follows:
 - If there is a marble on Vertex 0, move the marble into the box.
 - Move each marble from the vertex to its parent (all at once).
 - For each vertex occupied by two or more marbles, remove all the marbles from the vertex.
 - If there exists a vertex with some marbles, go to Step 1. Otherwise, end the play.
There are 2^{N+1} ways to place marbles on some of the vertices.
For each of them, find the number of marbles that will be in the box at the end of the play, and compute the sum of all those numbers modulo 1,000,000,007.

-----Constraints-----
 - 1 \leq N < 2 \times 10^{5}
 - 0 \leq p_i < i

-----Partial Scores-----
 - In the test set worth 400 points, N < 2{,}000.

-----Input-----
Input is given from Standard Input in the following format:
N
p_1 p_2 ... p_{N}

-----Output-----
Print the answer.

-----Sample Input-----
2
0 0

-----Sample Output-----
8

When we place a marble on both Vertex 1 and 2, there will be multiple marbles on Vertex 0 by step 2. In such a case, these marbles will be removed instead of being moved to the box.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import sys\nreadline = sys.stdin.readline\n\n \ndef parorder(Edge, p):\n    N = len(Edge)\n    par = [0]*N\n    par[p] = -1\n    stack = [p]\n    order = []\n    visited = set([p])\n    ast = stack.append\n    apo = order.append\n    while stack:\n        vn = stack.pop()\n        apo(vn)\n        for vf in Edge[vn]:\n            if vf in visited:\n                continue\n            visited.add(vf)\n            par[vf] = vn\n            ast(vf)\n    return par, order\n \ndef getcld(p):\n    res = [[] for _ in range(len(p))]\n    for i, v in enumerate(p[1:], 1):\n        res[v].append(i)\n    return res\n \n \n \nMOD = 10**9+7\nlimit = 1341398\np2 = [1]*limit\nfor i in range(1, limit):\n    p2[i] = 2*p2[i-1]%MOD\n\nN = int(readline())\nP = [None] + list(map(int, readline().split()))\nEdge = [[] for _ in range(N+1)]\nfor i in range(1, N+1):\n    Edge[i].append(P[i])\n    Edge[P[i]].append(i)\n_, L = parorder(Edge, 0)\nC = getcld(P)\ndist = [0]*(N+1)\nfor l in L[1:]:\n    p = P[l]\n    dist[l] = 1 + dist[p]\nmd = dist[:]\nfor l in L[:0:-1]:\n    p = P[l]\n    md[p] = max(md[p], md[l])\n\nCi = [None]*(N+1)\nfor i in range(N+1):\n    if C[i]:\n        res = -1\n        cc = None\n        for ci in C[i]:\n            if md[ci] > res:\n                res = md[ci]\n                cc = ci\n    Ci[i] = cc\nans = 0\n\nres = [[0]]\nval = [1]*(N+1) \nsize = [1]*(N+1) \nused = [0]*(N+1)\nname = [None]*(N+1)\nmark = [None]*(N+1)\nwhile res:\n    newres = []\n    for a in res:\n        ts = 1\n        ks = 0\n        ss = 0\n        dic = []\n        ctr = []\n\n        for i in a:\n            ts = ts*(p2[size[i]] - val[i])%MOD\n            ks = (ks + val[i]*pow(p2[size[i]] - val[i], MOD-2, MOD))%MOD\n            ss += size[i]\n\n            if not used[i]:\n                used[i] = 1\n                if C[i]:\n                    dic.append(C[i])\n                    if name[i] is None:\n                        name[i] = Ci[i]\n            if name[i] is not None:\n                ctr.append(name[i])\n        newres.extend(dic)\n        if len(ctr) > 1:\n            newres.append(ctr)\n        for a0 in a:\n            val[a0] = ts*ks%MOD\n            size[a0] = ss\n    ans = (ans + val[a0]*p2[N+1 - size[a0]])%MOD\n    res = [nr[:] for nr in newres]\n    #print(res)\nprint(ans)\n\n"""\ndef merge(sz, vl):\n    res = 0\n    ts = 1\n    ks = 0\n    for s, v in zip(sz, vl):\n        ts = ts*(p2[s] - v)%MOD\n        ks = (ks + v*pow(p2[s] - v, MOD-2, MOD))%MOD\n    return ts*ks%MOD\n\n\n\nassert N < 2000\n\nst = [0]\naa = 0\nwhile st:\n    size = [0]*(N+1)\n    val = [0]*(N+1)\n    cs = [[] for _ in range(N+1)]\n    cv = [[] for _ in range(N+1)]\n    \n    nr = []\n    for s in st:\n        cs[s] = [1]\n        cv[s] = [1]\n        nr.extend(C[s])\n    for l in L[::-1]:\n        size[l] = sum(cs[l])\n        val[l] = merge(cs[l], cv[l])\n        if l:\n            p = P[l]\n            cs[p].append(size[l])\n            cv[p].append(val[l])\n    aa = (aa + val[0]*p2[N+1 - size[0]])%MOD\n    st = nr[:]\n\nprint(aa)\n"""\n    \n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 53671765