Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote ai. Moreover, the girl wrote a positive integer to every edge of the tree (possibly, different integers on different edges).

Let's define dist(v, u) as the sum of the integers written on the edges of the simple path from v to u.

The vertex v controls the vertex u (v ≠ u) if and only if u is in the subtree of v and dist(v, u) ≤ au.

Alyona wants to settle in some vertex. In order to do this, she wants to know for each vertex v what is the number of vertices u such that v controls u.

Input

The first line contains single integer n (1 ≤ n ≤ 2·105).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the integers written in the vertices.

The next (n - 1) lines contain two integers each. The i-th of these lines contains integers pi and wi (1 ≤ pi ≤ n, 1 ≤ wi ≤ 109) — the parent of the (i + 1)-th vertex in the tree and the number written on the edge between pi and (i + 1).

It is guaranteed that the given graph is a tree.

Output

Print n integers — the i-th of these numbers should be equal to the number of vertices that the i-th vertex controls.

Examples

Input

5
2 5 1 4 6
1 7
1 1
3 5
3 6


Output

1 0 1 0 0


Input

5
9 7 8 6 5
1 1
2 1
3 1
4 1


Output

4 3 2 1 0

Note

In the example test case the vertex 1 controls the vertex 3, the vertex 3 controls the vertex 5 (note that is doesn't mean the vertex 1 controls the vertex 5).
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
    private static BufferedReader br;
    private static StringTokenizer st;
    private static PrintWriter pw;


    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        int N = readInt();
        AlyonaTree tree = new AlyonaTree(N);

        for (int i = 0; i < N; i++)
            tree.addValue(i, readLong());

        for (int i = 1; i < N; i++)
            tree.addAdj(readInt() - 1, i, readLong());

        int[] res = tree.solve();
        for (int i = 0; i < N; i++)
            pw.print(res[i] + " ");
        pw.println();
        pw.close();
    }

    private static void exitImmediately() {
        pw.close();
        System.exit(0);
    }

    private static long readLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private static double readDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private static int readInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
//            if (!br.ready()) {
//                exitImmediately();
//            }
            st = new StringTokenizer(br.readLine().trim());
        }
        return st.nextToken();
    }
}

class AlyonaTree {

    int N;
    int[] path;
    int pathLen;
    long[] distFromRoot;
    long[] value;
    int[] res;
    int[] numCtr; // numCtr[x] = the number of nodes that the parent of node x controls.
    List<Info>[] childList;

    public AlyonaTree(int n) {
        N = n;
        distFromRoot = new long[N];
        path = new int[N];
        value = new long[N];
        childList = new List[N];
        for (int i = 0; i < N; i++)
            childList[i] = new ArrayList<>();

        res = new int[N];
        numCtr = new int[N];
    }

    public void addValue(int idx, long val) {
        value[idx] = val;
    }

    public void addAdj(int node, int child, long cost) {
        childList[node].add(new Info(child, cost));
    }

    public int[] solve() {
        pathLen = 0;
        constructPath(0);

        for (int i = 0; i < N; i++) {
            for (Info child : childList[i]) {
                res[i] += numCtr[child.node];
            }
        }

        return res;
    }

    /*

    The key is that
    numCtr[x] = the number of nodes that the direct parent of `x` controls.

    Say there is a path a1 -> a2 -> a3 -> a4 -> ... -> aN -> x,
    and a3 is the furthest ancestor that controls x.
    i.e. a2 does not control `x`,but a3, a4, ..., aN controls `x`

    Then we want to do
    1) numCtr[x]++
    2) numCtr[a3]--

    And then tracing back from aN to all the way to the root,
    for each vertex 'y', we do
    numCtr[y] += the sum of numCtr[all child of y].

    In the above example, if we do the above, then numCtr[x]...numCtr[a4] increases by 1,
     and numCtr[a3] .. count[root] remains unchanged
     because numCtr[a3] is -1 from 2), and when we do numCtr[a3] += numCtr[a4], numCtr[a3] becomes 0.
 */
    private void constructPath(int node) {
        path[pathLen++] = node;
        for (Info child : childList[node]) {
            distFromRoot[child.node] = distFromRoot[node] + child.edgeCost;
            constructPath(child.node);
        }

        int up = 0;
        int down = pathLen - 1;
        int furthestAncestor = pathLen - 1; // furthest ancestor that controls the current node
        while (up <= down) {

            int mid = up + (down - up) / 2;
            int ancestor = path[mid];

            if ((distFromRoot[node] - distFromRoot[ancestor]) <= value[node]) {
                furthestAncestor = ancestor;
                down = mid - 1;
            } else {
                up = mid + 1;
            }
        }

        numCtr[node]++;
        numCtr[furthestAncestor]--;

        for (Info child : childList[node]) {
            numCtr[node] += numCtr[child.node];
        }
        pathLen--;

    }
}

class Info {
    int node;
    long edgeCost;

    public Info(int node, long edgeCost) {
        this.node = node;
        this.edgeCost = edgeCost;
    }
}
