Alyona decided to go on a diet and went to the forest to get some apples. There she unexpectedly found a magic rooted tree with root in the vertex 1, every vertex and every edge of which has a number written on.

The girl noticed that some of the tree's vertices are sad, so she decided to play with them. Let's call vertex *v* sad if there is a vertex *u* in subtree of vertex *v* such that *dist*(*v*, *u*) &gt; *a*<sub class="lower-index">*u*</sub>, where *a*<sub class="lower-index">*u*</sub> is the number written on vertex *u*, *dist*(*v*, *u*) is the sum of the numbers written on the edges on the path from *v* to *u*.

Leaves of a tree are vertices connected to a single vertex by a single edge, but the root of a tree is a leaf if and only if the tree consists of a single vertex — root.

Thus Alyona decided to remove some of tree leaves until there will be no any sad vertex left in the tree. What is the minimum number of leaves Alyona needs to remove?
In the first line of the input integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) is given — the number of vertices in the tree.

In the second line the sequence of *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>) is given, where *a*<sub class="lower-index">*i*</sub> is the number written on vertex *i*.

The next *n* - 1 lines describe tree edges: *i*<sup class="upper-index">*th*</sup> of them consists of two integers *p*<sub class="lower-index">*i*</sub> and *c*<sub class="lower-index">*i*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*,  - 10<sup class="upper-index">9</sup> ≤ *c*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>), meaning that there is an edge connecting vertices *i* + 1 and *p*<sub class="lower-index">*i*</sub> with number *c*<sub class="lower-index">*i*</sub> written on it.
The following image represents possible process of removing leaves from the tree:
9
88 22 83 14 95 91 98 53 11
3 24
7 -8
1 67
1 64
9 65
5 12
6 -80
3 8
5
6
53 82 15 77 71 23
5 -77
6 -73
2 0
1 26
4 -92
0
10
99 60 68 46 51 11 96 41 48 99
4 50
6 -97
3 -92
7 1
9 99
2 79
1 -15
8 -68
5 -84
7
8
53 41 22 22 34 95 56 24
3 -20
7 -56
5 -3
3 22
1 37
6 -34
2 32
1
8
2 19 83 95 9 87 15 6
6 16
7 98
5 32
7 90
8 37
2 -34
1 -83
5
6
60 89 33 64 92 75
4 50
1 32
5 21
3 77
1 86
4
4
14 66 86 37
3 -9
1 93
2 -57
3
9
59 48 48 14 51 51 86 53 58
1 -47
5 10
8 -6
9 46
2 -69
8 -79
9 92
6 12
5
3
17 26 6
1 -41
2 -66
0
7
63 3 67 55 14 19 96
4 35
1 -23
3 -66
2 80
3 80
2 -42
4
5
91 61 4 61 35
5 75
2 13
2 -15
1 90
4
19
40 99 20 54 5 31 67 73 10 46 70 68 80 74 7 58 75 25 13
13 -28
12 -33
9 -62
12 34
15 70
5 -22
7 83
2 -24
6 -64
17 62
14 -28
1 -83
4 34
8 -24
11 19
6 31
7 -8
16 90
11
39
98 80 74 31 81 15 23 52 54 86 56 9 95 91 29 20 97 78 62 65 17 95 12 39 77 17 60 78 76 51 36 56 74 66 43 23 17 9 13
15 21
34 -35
28 80
13 -15
29 -34
38 -8
18 10
18 19
27 54
7 42
16 49
12 90
39 33
20 53
2 91
33 59
29 -93
36 29
26 50
5 -12
33 -6
17 -60
27 7
17 85
31 63
26 80
1 -99
4 -40
10 -39
11 36
21 22
16 -15
14 -25
25 30
33 97
38 26
8 -78
10 -7
37
19
51 5 39 54 26 71 97 99 73 16 31 9 52 38 89 87 55 12 3
18 -94
19 -48
2 -61
10 72
1 -82
13 4
19 -40
16 -96
6 -16
19 -40
13 44
11 38
15 -7
6 8
18 -32
8 -75
3 58
10 -15
7
39
100 83 92 26 10 63 56 85 12 64 25 50 75 51 11 41 78 53 52 96 63 12 48 88 57 57 25 52 69 45 4 97 5 87 58 15 72 59 100
35 -60
33 -39
1 65
11 -65
34 -63
38 84
4 76
22 -9
6 -91
23 -65
18 7
2 -17
29 -15
19 26
29 23
14 -12
30 -72
9 14
12 -1
27 -21
32 -67
7 -3
26 -18
12 -45
33 75
14 -86
34 -46
24 -44
27 -29
22 -39
17 -73
36 -72
18 -76
27 -65
8 65
24 -15
35 79
27 61
38
2
83 33
1 67
1
6
538779323 241071283 506741761 673531032 208769045 334127496
1 -532301622
5 -912729787
6 -854756762
4 -627791911
2 -289935846
0
10
909382626 193846090 573881879 291637627 123338066 411896152 123287948 171497812 135534629 568762298
9 -257478179
4 -502075958
2 -243790121
2 -927464462
8 -89981403
1 -792322781
10 -326468006
7 -261940740
4 -565652087
0
import sys
sys.setrecursionlimit(1000000)
s=int(input())
b=input().split()
b=list(map(int,b))
f=[[] for c in range(s)]
for c in range(s-1):
  d=input().split()
  d=list(map(int,d))
  f[c+1].append((d[0]-1,d[1]))
  f[d[0]-1].append((c+1,d[1]))
a=1
viz=[0 for c in range(s)]
def dfs(no,soma):
  global a
  for c in range(len(f[no])):
    if soma+f[no][c][1]<=b[f[no][c][0]] and viz[f[no][c][0]]==0:
      a+=1
      viz[f[no][c][0]]+=1
      dfs(f[no][c][0],soma+f[no][c][1])


dfs(0,0)
print(s-a)
