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\n\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep="\\n")\n\ndef main():\n    def dfs(u=0):\n        def merge(dpu, dpv):\n            vn = len(dpv)\n            for d in range(-1, -1 - vn, -1):\n                u0, u1, u2 = dpu[d]\n                v0, v1, v2 = dpv[d]\n                n0 = (u0 * v0) % md\n                n1 = (u0 * v1 + u1 * v0) % md\n                n2 = (u2 * (v0 + v1 + v2) + v2 * (u0 + u1) + u1 * v1) % md\n                dpu[d] = (n0, n1, n2)\n\n        # 葉の場合\n        if len(to[u]) == 0:\n            return [(inv2, inv2, 0)]\n        # すべての子をマージ\n        dpu = []\n        mxlen=0\n        for v in to[u]:\n            dpv = dfs(v)\n            #深さが2段以上あったらu2をu0に\n            if not dpu:\n                dpu = dpv\n            else:\n                if len(dpu) < len(dpv): dpu, dpv = dpv, dpu\n                mxlen=max(mxlen,len(dpv))\n                merge(dpu, dpv)\n        for d in range(-1,-1-mxlen,-1):\n            u0,u1,u2=dpu[d]\n            dpu[d] = (u0 + u2, u1, 0)\n        dpu.append((inv2, inv2, 0))\n        return dpu\n\n    md = 10 ** 9 + 7\n    # 1/2のmod\n    inv2 = pow(2, md - 2, md)\n    n = int(input())\n    to = [[] for _ in range(n+1)]\n    pp = list(map(int, input().split()))\n    for i, p in enumerate(pp, 1):\n        to[p].append(i)\n    # print(to)\n    dp0 = dfs()\n    # print(dp0)\n    ans = sum(u1 for _, u1, _ in dp0)\n    print((ans * pow(2, n + 1, md)) % md)\n\nmain()\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14585