import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by yujiahao on 9/14/16.
 */
public class cf_358_c {
    private FastScanner in;
    private PrintWriter out;

    public void solve() throws IOException {
        int n = in.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = in.nextLong();
        ArrayList<ArrayList<pair_358>> graph = new ArrayList<ArrayList<pair_358>>();
        for (int i=0; i<n; i++) graph.add(new ArrayList<pair_358>());
        for (int i=1; i<=n-1; i++){
            int p = in.nextInt()-1;
            long c = in.nextInt();
            pair_358 cur1 = new pair_358(p, c);
            graph.get(i).add(cur1);
            pair_358 cur2 = new pair_358(i, c);
            graph.get(p).add(cur2);
        }

        int[] res = {0};
        long[] min = {Integer.MAX_VALUE};

        dfs(0, graph, res, 0L, min, a, -1);
        out.print(n-res[0]);
    }

    void dfs(int idx, ArrayList<ArrayList<pair_358>> graph, int[] res, long dis, long[] min, long[] a, int pre){
        long curA = a[idx];
        if (dis - min[0] > curA)    return;
        min[0] = Math.min(min[0], dis);
        min[0] = Math.max(0, min[0]);

        res[0]++;

        ArrayList<pair_358> neighbors = graph.get(idx);
        for (pair_358 next : neighbors){
            int nextP = next.p;
            long nextC = next.c;
            if (nextP == pre)   continue;
            dfs(nextP, graph, res, dis+nextC, min, a, idx);
        }
        return;
    }

    public void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() { return new BigInteger(next());}

    }

    public static void main(String[] arg) {
        new cf_358_c().run();
    }
}

class pair_358 {
    int p ;
    long c ;
    public pair_358(int p, long c){
        this.p = p;
        this.c = c;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by yujiahao on 9/14/16.
 */
public class cf_358_c {
    private FastScanner in;
    private PrintWriter out;

    public void solve() throws IOException {
        int n = in.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = in.nextLong();
        ArrayList<ArrayList<pair_358>> graph = new ArrayList<ArrayList<pair_358>>();
        for (int i=0; i<n; i++) graph.add(new ArrayList<pair_358>());
        for (int i=1; i<=n-1; i++){
            int p = in.nextInt()-1;
            long c = in.nextInt();
            pair_358 cur1 = new pair_358(p, c);
            graph.get(i).add(cur1);
            pair_358 cur2 = new pair_358(i, c);
            graph.get(p).add(cur2);
        }

        int[] res = {0};
        long min = Integer.MAX_VALUE;

        dfs(0, graph, res, 0L, min, a, -1);
        out.print(n-res[0]);
    }

    void dfs(int idx, ArrayList<ArrayList<pair_358>> graph, int[] res, long dis, long min, long[] a, int pre){
        long curA = a[idx];
        //if (dis<0)  dis = 0;
        if (dis - min > curA)    return;
        min = Math.min(min, dis);

        res[0]++;

        ArrayList<pair_358> neighbors = graph.get(idx);
        for (pair_358 next : neighbors){
            int nextP = next.p;
            long nextC = next.c;
            if (nextP == pre)   continue;
            dfs(nextP, graph, res, dis+nextC, min, a, idx);
        }
        return;
    }

    public void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() { return new BigInteger(next());}

    }

    public static void main(String[] arg) {
        new cf_358_c().run();
    }
}

class pair_358 {
    int p ;
    long c ;
    public pair_358(int p, long c){
        this.p = p;
        this.c = c;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by yujiahao on 9/14/16.
 */
public class cf_358_c {
    private FastScanner in;
    private PrintWriter out;

    public void solve() throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i=0; i<n; i++) a[i] = in.nextInt();
        ArrayList<ArrayList<pair_358>> graph = new ArrayList<ArrayList<pair_358>>();
        for (int i=0; i<n; i++) graph.add(new ArrayList<pair_358>());
        for (int i=1; i<=n-1; i++){
            int p = in.nextInt()-1;
            int c = in.nextInt();
            pair_358 cur1 = new pair_358(p, c);
            graph.get(i).add(cur1);
            pair_358 cur2 = new pair_358(i, c);
            graph.get(p).add(cur2);
        }

        int[] res = {0};
        int[] min = {Integer.MAX_VALUE};

        dfs(0, graph, res, 0, min, a, -1);
        out.print(n-res[0]);
    }

    void dfs(int idx, ArrayList<ArrayList<pair_358>> graph, int[] res, int dis, int[] min, int[] a, int pre){
        int curA = a[idx];
        if (dis - min[0] > curA)    return;
        min[0] = Math.min(min[0], dis);

        res[0]++;

        ArrayList<pair_358> neighbors = graph.get(idx);
        for (pair_358 next : neighbors){
            int nextP = next.p;
            int nextC = next.c;
            if (nextP == pre)   continue;
            dfs(nextP, graph, res, dis+nextC, min, a, idx);
        }
        return;
    }

    public void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() { return new BigInteger(next());}

    }

    public static void main(String[] arg) {
        new cf_358_c().run();
    }
}

class pair_358 {
    int p ;
    int c ;
    public pair_358(int p, int c){
        this.p = p;
        this.c = c;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by yujiahao on 9/14/16.
 */
public class cf_358_c {
    private FastScanner in;
    private PrintWriter out;

    public void solve() throws IOException {
        int n = in.nextInt();
        long[] a = new long[n];
        for (int i=0; i<n; i++) a[i] = in.nextLong();
        ArrayList<ArrayList<pair_358>> graph = new ArrayList<ArrayList<pair_358>>();
        for (int i=0; i<n; i++) graph.add(new ArrayList<pair_358>());
        for (int i=1; i<=n-1; i++){
            int p = in.nextInt()-1;
            long c = in.nextInt();
            pair_358 cur1 = new pair_358(p, c);
            graph.get(i).add(cur1);
            pair_358 cur2 = new pair_358(i, c);
            graph.get(p).add(cur2);
        }

        int[] res = {0};
        long[] min = {Integer.MAX_VALUE};

        dfs(0, graph, res, 0L, min, a, -1);
        out.print(n-res[0]);
    }

    void dfs(int idx, ArrayList<ArrayList<pair_358>> graph, int[] res, long dis, long[] min, long[] a, int pre){
        long curA = a[idx];
        if (dis - min[0] > curA)    return;
        min[0] = Math.min(min[0], dis);

        res[0]++;

        ArrayList<pair_358> neighbors = graph.get(idx);
        for (pair_358 next : neighbors){
            int nextP = next.p;
            long nextC = next.c;
            if (nextP == pre)   continue;
            dfs(nextP, graph, res, dis+nextC, min, a, idx);
        }
        return;
    }

    public void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() { return new BigInteger(next());}

    }

    public static void main(String[] arg) {
        new cf_358_c().run();
    }
}

class pair_358 {
    int p ;
    long c ;
    public pair_358(int p, long c){
        this.p = p;
        this.c = c;
    }
}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static long[] A;
    static long[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	long cost;
    	int v;
    	Pair(int v,long cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new long[n+1];
    	val=new long[n+1];
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextLong();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		long cost=sc.nextLong();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	dfs(1);
    	out.println(count.size());
      	out.close();
    }
    static void dfs(int src){
    	boolean flag=count.contains(src);
    	if(val[src]<0){
    		val[src]=0;
    	}
    	for(Pair nei:adj[src]){
    		if(flag){
    			count.add(nei.v);
    		}
    		else if(val[src]+nei.cost>A[nei.v]){
    			count.add(nei.v);
    		}
    		else{
    			if(nei.cost>val[src]+nei.cost){
    				val[nei.v]=nei.cost;
    			}
    			else{
    				val[nei.v]=val[src]+nei.cost;
    			}
    		}
    		dfs(nei.v);
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static long[] A;
    static long[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	long cost;
    	int v;
    	Pair(int v,long cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new long[n+1];
    	val=new long[n+1];
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextLong();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		long cost=sc.nextLong();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	dfs(1);
    	out.println(count.size());
      	out.close();
    }
    static void dfs(int src){
    	boolean flag=count.contains(src);
    	for(Pair nei:adj[src]){
    		if(flag){
    			count.add(nei.v);
    		}
    		else if(val[src]+nei.cost>A[nei.v]){
    			count.add(nei.v);
    		}
    		else{

    			if(nei.cost>val[src]+nei.cost){
    				val[nei.v]=nei.cost;
    			}
    			else{
    				val[nei.v]=val[src]+nei.cost;
    			}
    		}
    		dfs(nei.v);
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static int[] A;
    static int[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	int cost;
    	int v;
    	Pair(int v,int cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new int[n+1];
    	val=new int[n+1];
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextInt();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		int cost=sc.nextInt();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	dfs(1);
    	out.println(count.size());
      	out.close();
    }
    static void dfs(int src){
    	boolean flag=count.contains(src);
    	for(Pair nei:adj[src]){
    		if(flag){
    			count.add(nei.v);
    		}
    		else if(val[src]+nei.cost>A[nei.v]){
    			count.add(nei.v);
    		}
    		else{
    			val[nei.v]=val[src]+nei.cost;
    		}
    		dfs(nei.v);
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static long[] A;
    static long[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	long cost;
    	int v;
    	Pair(int v,long cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new long[n+1];
    	val=new long[n+1];
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextLong();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		long cost=sc.nextLong();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	dfs(1);
    	out.println(count.size());
      	out.close();
    }
    static void dfs(int src){
    	boolean flag=count.contains(src);
    	for(Pair nei:adj[src]){
    		if(flag){
    			count.add(nei.v);
    		}
    		else if(val[src]+nei.cost>A[nei.v]){
    			count.add(nei.v);
    		}
    		else{
    			val[nei.v]=val[src]+nei.cost;
    		}
    		dfs(nei.v);
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static long[] A;
    static long[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	long cost;
    	int v;
    	Pair(int v,long cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new long[n+1];
    	val=new long[n+1];
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextLong();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		long cost=sc.nextLong();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	count.add(1);
    	dfs(1);
    	out.println((n-count.size()));
    	//out.println(count);
    	//out.println(val[9]+" "+A[9]);
      	out.close();
    }
    static void dfs(int src){
    	if(val[src]<0L){
    		val[src]=0L;
    	}
    	for(Pair nei:adj[src]){
    		if(val[src]+nei.cost<A[nei.v]){
    			val[nei.v]=val[src]+nei.cost;
    			count.add(nei.v);
    			dfs(nei.v);
    		}
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static long[] A;
    static long[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	long cost;
    	int v;
    	Pair(int v,long cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new long[n+1];
    	val=new long[n+1];
    	Arrays.fill(val, 0L);
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextLong();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		long cost=sc.nextLong();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	count.add(1);
    	dfs(1);
    	out.println((n-count.size()));
    	//out.println(count);
    	//out.println(val[9]+" "+A[9]);
      	out.close();
    }
    static void dfs(int src){
    	if(val[src]<0L){
    		val[src]=0L;
    	}
    	for(Pair nei:adj[src]){
    		if(val[src]+nei.cost<=A[nei.v]){
    			val[nei.v]=val[src]+nei.cost;
    			count.add(nei.v);
    			dfs(nei.v);
    		}
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.math.*;
import java.io.*;
public class Luck{
	public static InputReader sc;
    public static PrintWriter out;
    public static final long MOD = (long)1e9 + 7L;
    static int n;
    static ArrayList<Pair>[] adj;
    static long[] A;
    static long[] val;
    static ArrayList<Integer> count=new ArrayList<Integer>();
    static class Pair{
    	long cost;
    	int v;
    	Pair(int v,long cost){
    		this.cost=cost;
    		this.v=v;
    	}
    }
    public static void main(String[] args){
    	sc=new InputReader(System.in);
    	out=new PrintWriter(System.out);
    	n=sc.nextInt();
    	adj=new ArrayList[n+1];
    	A=new long[n+1];
    	val=new long[n+1];
    	for(int i=1;i<=n;i++){
    		A[i]=sc.nextLong();
    		adj[i]=new ArrayList<Pair>();
    	}
    	for(int i=1;i<n;i++){
    		int p=sc.nextInt();
    		long cost=sc.nextLong();
    		adj[p].add(new Pair(i+1,cost));
    	}
    	count.add(1);
    	dfs(1);
    	out.println((n-count.size()));
    	//out.println(count);
    	//out.println(val[9]+" "+A[9]);
      	out.close();
    }
    static void dfs(int src){
    	if(val[src]<0){
    		val[src]=0;
    	}
    	for(Pair nei:adj[src]){
    		if(val[src]+nei.cost<A[nei.v]){
    			val[nei.v]=val[src]+nei.cost;
    			count.add(nei.v);
    			dfs(nei.v);
    		}
    	}
    }
    static void insert(Node root,int item){
    	if(item<=root.data){
    		if(root.left==null){
    			root.left=new Node(item);
    		}
    		else{
    			insert(root.left,item);
    		}
    	}
    	else{
    		if(root.right==null){
    			root.right=new Node(item);
    		}
    		else{
    			insert(root.right,item);
    		}
    	}
    }
    static class Node{
    	int data;
    	Node left;
    	Node right;
    	Node(int data){
    		this.data=data;
    		left=null;
    		right=null;
    	}
    }
//    static class Pair{
//    	String x;
//    	int y;
//    	Pair(){
//    		this.x="";
//    		this.y=-1;
//    	}
//    	Pair(String profit,int val,int count){
//    		this.x=profit;
//    		this.y=val;
//    	}
//    	public static Comparator<Pair> Val=new Comparator<Pair>(){
//    		public int compare(Pair p1,Pair p2){
//    			if(p1.x==p2.y){
//    				return p1.y-p2.y;
//    			}
//    			return (int)p1.x-(int)p2.x;
//    		}
//    	};
//    	public int hashCode() {
//    		final int prime = 31;
//    		int result = 1;
//    		result = prime * result + x;
//    		result = prime * result + x;
//    		return result;
//    	}
//    	public boolean equals(Object obj){
//    		if (this == obj)
//    	        return true;
//    	    if (!(obj instanceof Pair)) {
//    	        return false;
//    	    }
//
//    	    Pair p = (Pair) obj;
//    	    if(p.x!=this.x){
//    	    	return false;
//    	    }
//    	    else if(p.y!=p.y){
//    	    	return false;
//    	    }
//    	    return true;
//    	}
//    }
    static class DisjointSet{
    	int n;
    	int[] par;
    	int[] rank;
    	DisjointSet(int n){
    		this.n=n;
    		this.par=new int[n];
    		this.rank=new int[n];
    		makeSet();
    	}
    	void makeSet(){
    		for(int i=0;i<n;i++){
    			par[i]=i;
    			rank[i]=1;
    		}
    	}
    	void union(int x,int y){
    		int parX=parent(x);
    		int parY=parent(y);
    		if(parX!=parY){
    			if(rank[parX]>=rank[parY]){
    				rank[parX]+=rank[parY];
    				rank[parY]=0;
    				par[parY]=parX;
    			}
    			else{
    				rank[parY]+=rank[parX];
    				rank[parX]=0;
    				par[parX]=parY;
    			}
    		}
    	}
    	int parent(int c){
    		int i=c;
    		while(i!=par[i]){
    			i=par[i];
    		}
    		return i;
    	}
    }
    static int gcd(int a,int b){
    	if(b==0){
    		return a;
    	}
    	return gcd(b,a%b);

    }
    static int lcm(int a,int b){
    	int g;
    	if(a<b){
    		g=gcd(b,a);
    	}
    	else{
    		g=gcd(a,b);
    	}
    	return (a*b)/g;
    }

    static boolean isPrime(int n){
    	 if (n == 2)
    	        return true;
    	    for (long i = 2; i * i <= n; i++) {
    	        if (n % i == 0)
    	            return false;
    	    }
    	    return true;
    }

    static void shuffle(int[] A){
    	for(int i=A.length-1;i>0;i--){
    		int j=(int)(Math.random()*(i+1));
    		int temp=A[j];
    		A[j]=A[i];
    		A[i]=temp;
    	}
    }

//	public static class Node implements Comparable<Node>{
//	    int u;
//	    int v;
//	    public Node(){
//	    	;
//	    }
//	    public Node (int u, int v) {
//	    	this.u = u;
//	        this.v = v;
//	    }
//
//	    public void print() {
//	        out.println(v + " " + u + " ");
//	    }
//
//	    public int compareTo(Node n1){
//	    	return this.u-n1.u;
//	    }
//	}
	public static long power(long base,long exp,long mod){
		if(exp==0){
			return 1;
		}
		if(exp==1){
			return base;
		}
		long temp=exp/2;
		long val=power(base,temp,mod);
		long result=val*val;
		result=(result%mod);
		long AND=exp&1;
		if(AND==1){
			result*=base;
			result=(result%mod);
		}
		return result;
	}
	public static BigInteger pow(BigInteger base, BigInteger exp) {
	    if(exp.equals(new BigInteger(String.valueOf(0)))){
	        return new BigInteger(String.valueOf(1));
	    }
	    if(exp.equals(new BigInteger(String.valueOf(1))))
	        return base;
	    BigInteger temp=exp.divide(new BigInteger(String.valueOf(2)));
	    BigInteger val = pow(base, temp);
	    BigInteger result = val.multiply(val);
	    result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    BigInteger AND=exp.and(new BigInteger(String.valueOf(1)));
	    if(AND.equals(new BigInteger(String.valueOf(1)))){
	        result = result.multiply(base);
	        result=result.remainder(new BigInteger(String.valueOf(MOD)));
	    }
	    return result;
	}

	static class InputReader {

	    private InputStream stream;
	    private byte[] buf = new byte[8192];
	    private int curChar, snumChars;
	    private SpaceCharFilter filter;

	    public InputReader(InputStream stream) {
	        this.stream = stream;
	    }

	    public int snext() {
	        if (snumChars == -1)
	            throw new InputMismatchException();
	        if (curChar >= snumChars) {
	            curChar = 0;
	            try {
	                snumChars = stream.read(buf);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	            if (snumChars <= 0)
	                return -1;
	        }
	        return buf[curChar++];
	    }

	    public int nextInt() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        int res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        int sgn = 1;
	        if (c == '-') {
	            sgn = -1;
	            c = snext();
	        }
	        long res = 0;
	        do {
	            if (c < '0' || c > '9')
	                throw new InputMismatchException();
	            res *= 10;
	            res += c - '0';
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public int[] nextIntArray(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public String readString() {
	        int c = snext();
	        while (isSpaceChar(c))
	            c = snext();
	        StringBuilder res = new StringBuilder();
	        do {
	            res.appendCodePoint(c);
	            c = snext();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    public boolean isSpaceChar(int c) {
	        if (filter != null)
	            return filter.isSpaceChar(c);
	        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	    }

	    public interface SpaceCharFilter {
	        public boolean isSpaceChar(int ch);
	    }
	}

}


import java.util.*;
import java.io.*;

public class R682C {
    FastScanner in;
    PrintWriter out;
    long ans=1;
    ArrayList<Pair>[] v;
    boolean[] used;
    long[]a;

    void solve() {
        int n=in.nextInt();
        v = new ArrayList[n];
        used = new boolean[n];
        for(int i=0; i<n; i++) {
            v[i] = new ArrayList<>();
            used[i] = false;
        }

        a = new long[n];
        for(int i=0; i<n; i++)
            a[i]=in.nextInt();

        for(int i=1; i<n; i++) {
            int u=in.nextInt()-1;
            int d=in.nextInt();
            v[i].add(new Pair(u, d));
            v[u].add(new Pair(i, d));
        }

        used[0]=true;
        get(0, 0);
        System.out.println(n-ans);
    }

    void get(int u, long d) {
        for(Pair p : v[u])
            if (!used[p.n]) {
                used[p.n]=true;
                long dd=d+p.a;
                if (a[p.n]>dd) {
                    ans++;
                    get(p.n, dd);
                }
            }
    }

    static class Pair {
        public int n;
        public int a;
        public Pair(int n, int a) {
            this.n = n;
            this.a = a;
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("CF.in"));
            out = new PrintWriter(new File("CF.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

    public static void main(String[] args) {
        new R682C().runIO();
    }

}


import java.util.*;
import java.io.*;

public class R682C {
    FastScanner in;
    PrintWriter out;
    int ans=1;
    ArrayList<Pair>[] v;
    boolean[] used;
    int[]a;

    void solve() {
        int n=in.nextInt();
        v = new ArrayList[n];
        used = new boolean[n];
        for(int i=0; i<n; i++) {
            v[i] = new ArrayList<>();
            used[i] = false;
        }

        a = new int[n];
        for(int i=0; i<n; i++)
            a[i]=in.nextInt();

        for(int i=1; i<n; i++) {
            int u=in.nextInt()-1;
            int d=in.nextInt();
            v[i].add(new Pair(u, d));
            v[u].add(new Pair(i, d));
        }

        used[0]=true;
        get(0, 0);
        System.out.println(n-ans);
    }

    void get(int u, int d) {
        for(Pair p : v[u])
            if (!used[p.n]) {
                used[p.n]=true;
                int dd=Math.min(d+p.a, a[u]+p.a);
                if (a[p.n]>dd) {
                    ans++;
                    get(p.n, dd);
                }
            }
    }

    static class Pair {
        public int n;
        public int a;
        public Pair(int n, int a) {
            this.n = n;
            this.a = a;
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("CF.in"));
            out = new PrintWriter(new File("CF.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

    public static void main(String[] args) {
        new R682C().runIO();
    }

}


import java.util.*;
import java.io.*;

public class R682C {
    FastScanner in;
    PrintWriter out;
    long ans=1;
    ArrayList<Pair>[] v;
    boolean[] used;
    long[]a;

    void solve() {
        int n=in.nextInt();
        v = new ArrayList[n];
        used = new boolean[n];
        for(int i=0; i<n; i++) {
            v[i] = new ArrayList<>();
            used[i] = false;
        }

        a = new long[n];
        for(int i=0; i<n; i++)
            a[i]=in.nextInt();

        for(int i=1; i<n; i++) {
            int u=in.nextInt()-1;
            int d=in.nextInt();
            v[i].add(new Pair(u, d));
            v[u].add(new Pair(i, d));
        }

        used[0]=true;
        get(0, 0);
        System.out.println(n-ans);
    }

    void get(int u, long d) {
        for(Pair p : v[u])
            if (!used[p.n]) {
                used[p.n]=true;
                long dd=d+p.a;
                if (a[p.n]>=dd) {
                    ans++;
                    get(p.n, dd);
                }
            }
    }

    static class Pair {
        public int n;
        public int a;
        public Pair(int n, int a) {
            this.n = n;
            this.a = a;
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("CF.in"));
            out = new PrintWriter(new File("CF.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

    public static void main(String[] args) {
        new R682C().runIO();
    }

}


import java.util.*;
import java.io.*;

public class R682C {
    FastScanner in;
    PrintWriter out;
    long ans=1;
    ArrayList<Pair>[] v;
    boolean[] used;
    long[]a;

    void solve() {
        int n=in.nextInt();
        v = new ArrayList[n];
        used = new boolean[n];
        for(int i=0; i<n; i++) {
            v[i] = new ArrayList<>();
            used[i] = false;
        }

        a = new long[n];
        for(int i=0; i<n; i++)
            a[i]=in.nextInt();

        for(int i=1; i<n; i++) {
            int u=in.nextInt()-1;
            int d=in.nextInt();
            v[i].add(new Pair(u, d));
            v[u].add(new Pair(i, d));
        }

        used[0]=true;
        get(0, 0);
        System.out.println(n-ans);
    }

    void get(int u, long d) {
        for(Pair p : v[u])
            if (!used[p.n]) {
                used[p.n]=true;
                long dd=Math.max(d+p.a, p.a);
                if (a[p.n]>=dd) {
                    ans++;
                    get(p.n, dd);
                }
            }
    }

    static class Pair {
        public int n;
        public int a;
        public Pair(int n, int a) {
            this.n = n;
            this.a = a;
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("CF.in"));
            out = new PrintWriter(new File("CF.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

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

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

    public static void main(String[] args) {
        new R682C().runIO();
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ernesto Carvajal
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] vertexNumber;
        int[] subtreeSize;
        int[] subtreeSolution;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            vertexNumber = new int[n];
            subtreeSize = new int[n];
            subtreeSolution = new int[n];
            int[] parent = new int[n - 1];
            long[] weight = new long[n - 1];

            for (int i = 0; i < n; i++) {
                vertexNumber[i] = in.readInt();
            }
            for (int i = 0; i < n - 1; i++) {
                parent[i] = in.readInt() - 1;
                weight[i] = in.readLong();
            }

            Graph graph = Graph.createWeightedTree(parent, weight);
            calculateSolutions(graph, 0, 0);
            out.printLine(subtreeSolution[0]);
        }

        private void calculateSolutions(Graph graph, int node, long distanceToRoot) {
            subtreeSize[node] = 1;
            for (int i = graph.firstOutbound(node); i != -1; i = graph.nextOutbound(i)) {
                int child = graph.destination(i);
                long weight = graph.weight(i);
                calculateSolutions(graph, child, distanceToRoot + weight);
                subtreeSize[node] += subtreeSize[child];
                subtreeSolution[node] += subtreeSolution[child];
            }
            boolean needsToBeRemoved = distanceToRoot > vertexNumber[node];
            if (needsToBeRemoved) {
                subtreeSolution[node] = subtreeSize[node];
            }
        }

    }

    static interface Edge {
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }

    static class Graph {
        public static final int REMOVED_BIT = 0;
        protected int vertexCount;
        protected int edgeCount;
        private int[] firstOutbound;
        private int[] firstInbound;
        private Edge[] edges;
        private int[] nextInbound;
        private int[] nextOutbound;
        private int[] from;
        private int[] to;
        private long[] weight;
        public long[] capacity;
        private int[] reverseEdge;
        private int[] flags;

        public Graph(int vertexCount) {
            this(vertexCount, vertexCount);
        }

        public Graph(int vertexCount, int edgeCapacity) {
            this.vertexCount = vertexCount;
            firstOutbound = new int[vertexCount];
            Arrays.fill(firstOutbound, -1);

            from = new int[edgeCapacity];
            to = new int[edgeCapacity];
            nextOutbound = new int[edgeCapacity];
            flags = new int[edgeCapacity];
        }

        public static Graph createWeightedTree(int[] parent, long[] weight) {
            Graph graph = new Graph(parent.length + 1, parent.length);
            for (int i = 0; i < parent.length; i++)
                graph.addWeightedEdge(parent[i], i + 1, weight[i]);
            return graph;
        }

        public int addEdge(int fromID, int toID, long weight, long capacity, int reverseEdge) {
            ensureEdgeCapacity(edgeCount + 1);
            if (firstOutbound[fromID] != -1)
                nextOutbound[edgeCount] = firstOutbound[fromID];
            else
                nextOutbound[edgeCount] = -1;
            firstOutbound[fromID] = edgeCount;
            if (firstInbound != null) {
                if (firstInbound[toID] != -1)
                    nextInbound[edgeCount] = firstInbound[toID];
                else
                    nextInbound[edgeCount] = -1;
                firstInbound[toID] = edgeCount;
            }
            this.from[edgeCount] = fromID;
            this.to[edgeCount] = toID;
            if (capacity != 0) {
                if (this.capacity == null)
                    this.capacity = new long[from.length];
                this.capacity[edgeCount] = capacity;
            }
            if (weight != 0) {
                if (this.weight == null)
                    this.weight = new long[from.length];
                this.weight[edgeCount] = weight;
            }
            if (reverseEdge != -1) {
                if (this.reverseEdge == null) {
                    this.reverseEdge = new int[from.length];
                    Arrays.fill(this.reverseEdge, 0, edgeCount, -1);
                }
                this.reverseEdge[edgeCount] = reverseEdge;
            }
            if (edges != null)
                edges[edgeCount] = createEdge(edgeCount);
            return edgeCount++;
        }

        protected final GraphEdge createEdge(int id) {
            return new GraphEdge(id);
        }

        public final int addFlowWeightedEdge(int from, int to, long weight, long capacity) {
            if (capacity == 0) {
                return addEdge(from, to, weight, 0, -1);
            } else {
                int lastEdgeCount = edgeCount;
                addEdge(to, from, -weight, 0, lastEdgeCount + entriesPerEdge());
                return addEdge(from, to, weight, capacity, lastEdgeCount);
            }
        }

        protected int entriesPerEdge() {
            return 1;
        }

        public final int addWeightedEdge(int from, int to, long weight) {
            return addFlowWeightedEdge(from, to, weight, 0);
        }

        public final int firstOutbound(int vertex) {
            int id = firstOutbound[vertex];
            while (id != -1 && isRemoved(id))
                id = nextOutbound[id];
            return id;
        }

        public final int nextOutbound(int id) {
            id = nextOutbound[id];
            while (id != -1 && isRemoved(id))
                id = nextOutbound[id];
            return id;
        }

        public final int destination(int id) {
            return to[id];
        }

        public final long weight(int id) {
            if (weight == null)
                return 0;
            return weight[id];
        }

        public final boolean flag(int id, int bit) {
            return (flags[id] >> bit & 1) != 0;
        }

        public final boolean isRemoved(int id) {
            return flag(id, REMOVED_BIT);
        }

        protected void ensureEdgeCapacity(int size) {
            if (from.length < size) {
                int newSize = Math.max(size, 2 * from.length);
                if (edges != null)
                    edges = resize(edges, newSize);
                from = resize(from, newSize);
                to = resize(to, newSize);
                nextOutbound = resize(nextOutbound, newSize);
                if (nextInbound != null)
                    nextInbound = resize(nextInbound, newSize);
                if (weight != null)
                    weight = resize(weight, newSize);
                if (capacity != null)
                    capacity = resize(capacity, newSize);
                if (reverseEdge != null)
                    reverseEdge = resize(reverseEdge, newSize);
                flags = resize(flags, newSize);
            }
        }

        protected final int[] resize(int[] array, int size) {
            int[] newArray = new int[size];
            System.arraycopy(array, 0, newArray, 0, array.length);
            return newArray;
        }

        private long[] resize(long[] array, int size) {
            long[] newArray = new long[size];
            System.arraycopy(array, 0, newArray, 0, array.length);
            return newArray;
        }

        private Edge[] resize(Edge[] array, int size) {
            Edge[] newArray = new Edge[size];
            System.arraycopy(array, 0, newArray, 0, array.length);
            return newArray;
        }

        protected class GraphEdge implements Edge {
            protected int id;

            protected GraphEdge(int id) {
                this.id = id;
            }

        }

    }
}


#include <bits/stdc++.h>

#define X first
#define Y second
#define FOR(i, a, b) for (i=(a); i <= (b); i++)
#define FORD(i, a, b) for (i=(a); i >= (b); i--)
#define itr(t) vector<t>::iterator
#define ritr(t) vector<t>::reverse_iterator
#define IT(i, v) for (i=(v)->begin(); i != (v)->end(); i++)
#define RIT(i, v) for (i=(v)->rbegin(); i != (v)->rend(); i++)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MAX_HEAP(t) priority_queue<t>
#define MIN_HEAP(t) priority_queue<t, vector<t>, greater<t> >
#define input_file "input.txt"
#define output_file "output.txt"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ll> vi;
typedef stack<int> si;

inline ll gcd(ll a, ll b)
{
    return (a ? gcd(b%a, a) : b);
}

#define N 111111
#define M 290611

int n, i;
ll l, x, y, sum, a[N];
vi h[M];

inline bool have(ll x)
{
	if (x < 0) return false;
	itr(ll) it;
	x%=M;
	IT(it, &h[x])
		if (*it==x)
		{
			//if (x==1233723461) cout << "have" << endl;
			return true;
		}
	return false;
}

inline void Append(ll x)
{
	h[x%M].push_back(x);
}

inline void Add(ll x)
{
	int i, j;
	ll other=sum-x;
	bool exist=false;
	FOR(i, 1, n)
		if (have(a[i]+x))
		{
			FOR(j, 1, n)
				if (have(a[j]+other))
				{
					printf("0");
					exit(0);
				}
			if (a[i]+x==1233723461) cout << have(a[i]+x) << endl;
			//if (x==646231028) cout << a[i]+x << endl;
			cout << 1 << endl << other;
			exit(0);
		}
	FOR(i, 1, n)
	{
		if (a[i]+x <= l and (have(a[i]+x-other) or have(a[i]+x+other)))
		{
			cout << 1 << endl << a[i]+x;
			exit(0);
		}
		if (a[i]-x >= 0 and (have(a[i]-x-other) or have(a[i]-x+other)))
		{
			cout << 1 << endl << a[i]-x;
			exit(0);
		}
	}
}

main()
{
    //freopen(input_file, "r", stdin);
    //freopen(output_file, "w", stdout);
    cin >> n >> l >> x >> y;
    sum=x+y;
    FOR(i, 1, n)
    {
    	cin >> a[i];
    	Append(a[i]);
    }
    Add(x);
    Add(y);
    cout << 2 << endl << x << " " << y;
}


#include <bits/stdc++.h>

#define X first
#define Y second
#define FOR(i, a, b) for (i=(a); i <= (b); i++)
#define FORD(i, a, b) for (i=(a); i >= (b); i--)
#define itr(t) vector<t>::iterator
#define ritr(t) vector<t>::reverse_iterator
#define IT(i, v) for (i=(v)->begin(); i != (v)->end(); i++)
#define RIT(i, v) for (i=(v)->rbegin(); i != (v)->rend(); i++)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MAX_HEAP(t) priority_queue<t>
#define MIN_HEAP(t) priority_queue<t, vector<t>, greater<t> >
#define input_file "input.txt"
#define output_file "output.txt"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ll> vi;
typedef stack<int> si;

inline ll gcd(ll a, ll b)
{
    return (a ? gcd(b%a, a) : b);
}

#define N 111111
#define M 290611

int n, i;
ll l, x, y, sum, a[N];
vi h[M];

inline bool have(ll x)
{
	if (x < 0) return false;
	itr(ll) it;
	x%=M;
	IT(it, &h[x])
		if (*it==x)
		{
			if (x==1233723461) cout << "have" << endl;
			return true;
		}
	return false;
}

inline void Append(ll x)
{
	h[x%M].push_back(x);
}

inline void Add(ll x)
{
	int i, j;
	ll other=sum-x;
	bool exist=false;
	FOR(i, 1, n)
		if (have(a[i]+x))
		{
			FOR(j, 1, n)
				if (have(a[j]+other))
				{
					printf("0");
					exit(0);
				}
			//if (x==646231028) cout << a[i]+x << endl;
			cout << 1 << endl << other;
			exit(0);
		}
	FOR(i, 1, n)
	{
		if (a[i]+x <= l and (have(a[i]+x-other) or have(a[i]+x+other)))
		{
			cout << 1 << endl << a[i]+x;
			exit(0);
		}
		if (a[i]-x >= 0 and (have(a[i]-x-other) or have(a[i]-x+other)))
		{
			cout << 1 << endl << a[i]-x;
			exit(0);
		}
	}
}

main()
{
    //freopen(input_file, "r", stdin);
    //freopen(output_file, "w", stdout);
    cin >> n >> l >> x >> y;
    sum=x+y;
    FOR(i, 1, n)
    {
    	cin >> a[i];
    	Append(a[i]);
    }
    Add(x);
    Add(y);
    cout << 2 << endl << x << " " << y;
}


#include <bits/stdc++.h>

#define X first
#define Y second
#define FOR(i, a, b) for (i=(a); i <= (b); i++)
#define FORD(i, a, b) for (i=(a); i >= (b); i--)
#define itr(t) vector<t>::iterator
#define ritr(t) vector<t>::reverse_iterator
#define IT(i, v) for (i=(v)->begin(); i != (v)->end(); i++)
#define RIT(i, v) for (i=(v)->rbegin(); i != (v)->rend(); i++)
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MAX_HEAP(t) priority_queue<t>
#define MIN_HEAP(t) priority_queue<t, vector<t>, greater<t> >
#define input_file "input.txt"
#define output_file "output.txt"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef stack<int> si;

inline ll gcd(ll a, ll b)
{
    return (a ? gcd(b%a, a) : b);
}

#define N 111111
#define M 290611

int n, i, l, x, y, sum, a[N];
vi h[M];

inline bool have(int x)
{
	if (x < 0) return false;
	itr(int) it;
	x%=M;
	IT(it, &h[x])
		if (*it==x) return true;
	return false;
}

inline void Append(int x)
{
	h[x%M].push_back(x);
}

inline void Add(int x)
{
	int i, j, other=sum-x;
	bool exist=false;
	FOR(i, 1, n)
		if (have(a[i]+x))
		{
			FOR(j, 1, n)
				if (have(a[j]+other))
				{
					printf("0");
					exit(0);
				}
			printf("1\n%d", other);
			exit(0);
		}
	FOR(i, 1, n)
	{
		if (a[i]+x <= l and (have(a[i]+x-other) or have(a[i]+x+other)))
		{
			printf("1\n%d", a[i]+x);
			exit(0);
		}
		if (a[i]-x >= 0 and (have(a[i]-x-other) or have(a[i]-x+other)))
		{
			printf("1\n%d", a[i]-x);
			exit(0);
		}
	}
}

main()
{
    //freopen(input_file, "r", stdin);
    //freopen(output_file, "w", stdout);
    scanf("%d%d%d%d", &n, &l, &x, &y);
    sum=x+y;
    FOR(i, 1, n)
    {
    	scanf("%d", &a[i]);
    	Append(a[i]);
    }
    Add(x);
    Add(y);
    printf("2\n%d %d", x, y);
}