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.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

public class A {
    static class Node implements Comparable<Node>{
        int x;
        long cost;
        public Node(int x,long cost){
            this.x=x;
            this.cost=cost;
        }
        public int compareTo(Node c){
            return 0;
        }
        @Override
        public boolean equals(Object o){
            if(o instanceof Node){
                Node c = (Node)o;

            }
            return false;
        }
    }
    //public static PrintWriter pw;
    public static PrintWriter pw = new PrintWriter(System.out);

    public static void solve() throws IOException {
//	pw=new PrintWriter(new FileWriter("C:\\Users\\shree\\Downloads\\small_output_in"));
        FastReader sc = new FastReader();
        int n=sc.I();
        a=new long[n+1];
        for(int i=1;i<=n;i++) a[i]=sc.L();
        graph=new Vector[n+1];
        parent=new int[n+1];
        for(int i=1;i<=n;i++) graph[i]=new Vector<>();
        for(int i=1;i<n;i++){
            int p=sc.I(); long cost=sc.L();
            graph[i+1].add(new Node(p,cost));
            graph[p].add(new Node(i+1,cost));
            parent[i+1]=p;
        }
        vis=new boolean[n+1];
        stk=new Node[n+1];
        ans=new long[n+1];
        dfs(1,0);
        go(1,-1);
        for(int i=1;i<=n;i++) pw.print(ans[i]+" ");
        pw.close();


    }

    static long a[];
    static Vector<Node> graph[];
    static Node stk[];
    static int k=0;
    static boolean vis[];
    static int parent[];
    static long ans[];
    static void dfs(int v,long cost){
        vis[v]=true;
        stk[k++]=new Node(v,cost);
        int id=lower_bound(stk,k-1,cost-a[v]);
       // pw.println(id+" "+v);
        if(id>0 &&  parent[id]>0) ans[parent[id]]-=1;
        if(parent[v]>0) ans[parent[v]]++;


        for(Node p : graph[v]){
            if(!vis[p.x]){

                dfs(p.x,cost+p.cost);
            }
        }
        stk[--k]=null;
    }
    static int lower_bound(Node a[], int n, long x) {
        int l = 0;
        int h = n;
        int id=0;
        while (l <= h) {
            int mid = (l + h) / 2;
            if (x <= a[mid].cost) {
                h = mid -1;
                id=a[mid].x;
            } else {
                l=mid+1;
            }
        }

      // return a[l].x;
      //  System.out.println(id);
        return id;

    }
    static void go(int v,int pr){
        for(Node p : graph[v]){
            if(p.x!=pr) {
                go(p.x,v);
                ans[v] += ans[p.x];
            }
        }
    }
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                try {

                    solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1 << 26).start();

    }

    static BufferedReader br;
    static long M = (long) 1e9 + 7;

    static class FastReader {

        StringTokenizer st;

        public FastReader() throws FileNotFoundException {
            //br=new BufferedReader(new FileReader("C:\\Users\\shree\\Downloads\\B-small-practice.in"));
            br = new BufferedReader(new InputStreamReader(System.in));

        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int I() {
            return Integer.parseInt(next());
        }

        long L() {
            return Long.parseLong(next());
        }

        double D() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public boolean hasNext() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return false;
                }
                st = new StringTokenizer(s);
            }
            return true;
        }

    }
}