#include<iostream>
#include<vector>
#include<cstring>
#define N 100005
using namespace std;

long long int a[N];
vector<long long int> v[N];
vector<long long int> w[N];
int sub[N];
bool vis[N];
int ans = 0;

int dfs(int s){
    vis[s] = true;
    if(v[s].size()==1 && s!=1){
        sub[v[s][0]] = 0;
        return 0;
    }
    for(long long int i=0;i<v[s].size();i++){
        if(!vis[v[s][i]]){
         sub[s] = sub[s] + (dfs(v[s][i])+1);
        }
    }
    return sub[s];
}

void dfs1(int s,long long int maxd,long long int wt){
    vis[s] = 1;
    maxd = max(maxd+wt,wt);
    if(maxd>a[s]){
        ans += (sub[s]+1);
        return;
    }
    for(int i=0;i<v[s].size();i++){
        int c = v[s][i];
        wt = w[s][i];
        if(!vis[c]){
            dfs1(c,maxd,wt);
        }
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    long long int p,c;
    for(int i=1;i<n;i++){
        cin>>p>>c;
        v[i+1].push_back(p);
        v[p].push_back(i+1);
        w[i+1].push_back(c);
        w[p].push_back(c);
    }
    memset(sub,0,sizeof(sub));
    memset(vis,0,sizeof(vis));
    dfs(1);
    // for(int i=1;i<=n;i++)
    // cout<<sub[i]<<" ";
    // cout<<endl;
    memset(vis,0,sizeof(vis));
    dfs1(1,0,0);
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
ll sum[maxn];
ll size[maxn];
ll val[maxn];
//ll head[2*maxn],ver[2*maxn],nxt[2*maxn],edge[2*maxn];
int tot;
vector<int> vec;
vector<int> e[maxn];
vector<int> edge[maxn];
//void add(int u,int v,int w)
//{
//	ver[++tot]=v;
//	edge[tot]=w;
//	nxt[tot]=head[u];
//	head[u]=tot;
//}

void dfs1(int u,int fa)
{
	size[u]=1;
	for(int i=0; i<e[u].size(); i++)
	{
		int v=e[u][i];
		if(v==fa) continue;
		dfs1(v,u);
		size[u]+=size[v];
	}
}

void dfs2(int u,int fa)
{
	if(sum[fa]>0) sum[u]=sum[fa];
	else sum[u]=0;
	for(int i=0; i<e[u].size(); i++)
	{
		int v=e[u][i];
		if(v==fa) continue;
		int w=edge[u][i];
		if((sum[u]+w)>val[v])
		{
			vec.push_back(v);
			continue;
		}
		else
		{
			sum[u]+=w;
			dfs2(v,u);
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%lld",&val[i]);
	for(int i=1; i<=n-1; i++)
	{
		ll v,w;
		scanf("%lld%lld",&v,&w);
//		add(i+1,v,w);
//		add(v,i+1,w);
		e[i+1].push_back(v);
		edge[i+1].push_back(w);
		e[v].push_back(i+1);
		edge[v].push_back(w);
	}
	dfs1(1,0);
	dfs2(1,0);
	int ans=0;
	for(auto i:vec)
		ans+=size[i];
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
ll sum[maxn];
ll val[maxn];
int head[2*maxn],ver[2*maxn],nxt[2*maxn];
ll edge[2*maxn];
int tot;
int ans=0;
void add(int u,int v,ll w)
{
	ver[++tot]=v;
	edge[tot]=w;
	nxt[tot]=head[u];
	head[u]=tot;
}
void dfs(int u,int fa)
{
	if(sum[u]<=val[u])
		ans++;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];
		if(v==fa) continue;
		ll w=edge[i];

		if(sum[u]+w>0)
			sum[v]=sum[u]+w;
		else
			sum[v]=0;
		dfs(v,u);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&val[i]);
	for(int i=1; i<=n-1; i++)
	{
		ll v,w;
		scanf("%lld%lld",&v,&w);
		add(i+1,v,w);
		add(v,i+1,w);
	}
	dfs(1,0);
	printf("%d",n-ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
ll sum[maxn];
ll size[maxn];
ll val[maxn];
ll head[2*maxn],ver[2*maxn],nxt[2*maxn],edge[2*maxn];
int tot;
vector<int> vec;
void add(int u,int v,int w)
{
	ver[++tot]=v;
	edge[tot]=w;
	nxt[tot]=head[u];
	head[u]=tot;
}

void dfs1(int u,int fa)
{
	size[u]=1;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];

		if(v==fa) continue;
		dfs1(v,u);
		size[u]+=size[v];
	}
}

void dfs2(int u,int fa)
{
	if(sum[fa]>0) sum[u]=sum[fa];
	else sum[u]=0;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];
		if(v==fa) continue;
		int w=edge[i];
		if((sum[u]+w)>val[v])
		{
			vec.push_back(v);
			continue;
		}
		else
		{
			sum[u]+=w;
			dfs2(v,u);
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&val[i]);
	for(int i=1; i<=n-1; i++)
	{
		int v,w;
		scanf("%d%d",&v,&w);
		add(i+1,v,w);
		add(v,i+1,w);
	}
	dfs1(1,0);
	dfs2(1,0);
	int ans=0;
	for(auto i:vec)
		ans+=size[i];
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
ll sum[maxn];
ll size[maxn];
ll val[maxn];
ll head[2*maxn],ver[2*maxn],nxt[2*maxn],edge[2*maxn];
int tot;
vector<int> vec;
void add(int u,int v,int w)
{
	ver[++tot]=v;
	edge[tot]=w;
	nxt[tot]=head[u];
	head[u]=tot;
}

void dfs1(int u,int fa)
{
	size[u]=1;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];

		if(v==fa) continue;
		dfs1(v,u);
		size[u]+=size[v];
	}
}

void dfs2(int u,int fa)
{
	if(sum[fa]>0) sum[u]=sum[fa];
	else sum[u]=0;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];
		if(v==fa) continue;
		int w=edge[i];
		if((sum[u]+w)>val[v])
		{
			vec.push_back(v);
			continue;
		}
		else
		{
			sum[u]+=w;
			dfs2(v,u);
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%lld",&val[i]);
	for(int i=1; i<=n-1; i++)
	{
		ll v,w;
		scanf("%lld%lld",&v,&w);
		add(i+1,v,w);
		add(v,i+1,w);
	}
	dfs1(1,0);
	dfs2(1,0);
	int ans=0;
	for(auto i:vec)
		ans+=size[i];
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
ll sum[maxn];
ll size[maxn];
ll val[maxn];
ll head[maxn],ver[maxn],nxt[maxn],edge[maxn];
int tot;
vector<int> vec;
void add(int u,int v,int w)
{
	ver[++tot]=v;
	edge[tot]=w;
	nxt[tot]=head[u];
	head[u]=tot;
}

void dfs1(int u,int fa)
{
	size[u]=1;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];

		if(v==fa) continue;
		dfs1(v,u);
		size[u]+=size[v];
	}
}

void dfs2(int u,int fa)
{
	if(sum[fa]>0) sum[u]=sum[fa];
	else sum[u]=0;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];
		if(v==fa) continue;
		int w=edge[i];
		if((sum[u]+w)>val[v])
		{
			vec.push_back(v);
			continue;
		}
		else
		{
			sum[u]+=w;
			dfs2(v,u);
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&val[i]);
	for(int i=1; i<=n-1; i++)
	{
		int v,w;
		scanf("%d%d",&v,&w);
		add(i+1,v,w);
		add(v,i+1,w);
	}
	dfs1(1,0);
	dfs2(1,0);
	int ans=0;
	for(auto i:vec)
		ans+=size[i];
	printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+10;
ll sum[maxn];
ll val[maxn];
int head[2*maxn],ver[2*maxn],nxt[2*maxn];
ll edge[2*maxn];
int tot;
int ans=0;
void add(int u,int v,ll w)
{
	ver[++tot]=v;
	edge[tot]=w;
	nxt[tot]=head[u];
	head[u]=tot;
}
void dfs(int u,int fa)
{
	if(sum[u]<=val[u])
		ans++;
	else
		return;
	for(int i=head[u]; i; i=nxt[i])
	{
		int v=ver[i];
		if(v==fa) continue;
		ll w=edge[i];
		if(sum[u]+w>0)
			sum[v]=sum[u]+w;
		else
			sum[v]=0;
		dfs(v,u);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d",&val[i]);
	for(int i=2; i<=n; i++)
	{
		int v;
		ll w;
		scanf("%d%lld",&v,&w);
		add(i,v,w);
		add(v,i,w);
	}
	dfs(1,0);
	printf("%d",n-ans);
}


#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

ll n, ans, sums[100100], g[100100], x, y; bool viz[100100], seen[100100];
vector <pair <ll, ll> > v[100100];

void fall(int x){
	viz[x] = 1;
	seen[x] = 1;
	for(auto nod : v[x]){
		if(!seen[nod.st] && !viz[nod.st]){
			fall(nod.st);
		}
	}
}

void dfs(int x){
	viz[x] = 1;
	for(auto nod : v[x]){
		if(!viz[nod.st]){
			sums[nod.st] = sums[x] + nod.nd;
			if(g[nod.st] < max(sums[nod.st], nod.nd)) fall(nod.st);
			else dfs(nod.st);
		}
	}
}

int main(){
//	ifstream cin("tst.in");
	//ofstream out("tst.out");
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> g[i];
	for(int i = 1; i < n; i++){
		cin >> x >> y;
		v[x].pb(mp(i+1, y));
		v[i+1].pb(mp(x, y));
	}
	dfs(1);
	for(int i = 1; i <= n; i++) if(seen[i]) ans++;
	cout << ans;
//	for(int i = 1; i <= n; i++){
//		out << i << " -> ";
//		for(auto nod : v[i]) out << nod.st << ' ';
///		out << '\n';
//	}
	//for(int i = 1; i <= n; i++) cout << sums[i] << ' ';
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define st first
#define nd second

using namespace std;

ll n, x, y, g[100100], sums[100100]; bool viz[100100], seen[100100];
vector <pair <ll, ll> > v[100100];

void fall(ll x){
	seen[x] = 1;
	viz[x] = 1;
	for(int i = 0; i < v[x].size(); i++){
		pair <ll, ll> nod = v[x][i];
		if(!seen[nod.st] && !viz[nod.st]){
			fall(nod.st);
		}
	}
}

void dfs(ll x){
	viz[x] = 1;
	for(int i = 0; i < v[x].size(); i++){
		pair <ll, ll> nod = v[x][i];
		if(!viz[nod.st]){
			sums[nod.st] = sums[x] + nod.nd;
			if(sums[nod.st] > nod.nd) fall(nod.st);
			else dfs(nod.st);
		}
	}
}

int main(){
	//ifstream in("tst.in");
	//ofstream out("tst.out");
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> g[i];
	for(int i = 1; i < n; i++){
		cin >> x >> y;
		v[i+1].pb(mp(x, y));
		v[x].pb(mp(i+1, y));
	}
	dfs(1);
	int ans = 0;
	for(int i = 1; i <= n; i++) if(seen[i] != 0) ans++;
//	for(int i = 1; i <= n; i++) out << sums[i] << ' ';
	cout << ans-1;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define st first
#define nd second

using namespace std;

ll n, x, y, g[100100], sums[100100]; bool viz[100100], seen[100100];
vector <pair <ll, ll> > v[100100];

void fall(ll x){
	seen[x] = 1;
	viz[x] = 1;
	for(int i = 0; i < v[x].size(); i++){
		pair <ll, ll> nod = v[x][i];
		if(!seen[nod.st] && !viz[nod.st]){
			fall(nod.st);
		}
	}
}

void dfs(ll x){
	viz[x] = 1;
	for(int i = 0; i < v[x].size(); i++){
		pair <ll, ll> nod = v[x][i];
		if(!viz[nod.st]){
			sums[nod.st] = sums[x] + nod.nd;
			if(sums[nod.st] > nod.nd) fall(nod.st);
			else dfs(nod.st);
		}
	}
}

int main(){
	//ifstream in("tst.in");
	//ofstream out("tst.out");
	cin >> n;
	for(int i = 1; i <= n; i++) in >> g[i];
	for(int i = 1; i < n; i++){
		cin >> x >> y;
		v[i+1].pb(mp(x, y));
		v[x].pb(mp(i+1, y));
	}
	dfs(1);
	int ans = 0;
	for(int i = 1; i <= n; i++) if(seen[i] != 0) ans++;
//	for(int i = 1; i <= n; i++) out << sums[i] << ' ';
	cout << ans-1;
	return 0;
}


#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

ll n, ans, sums[100100], g[100100], x, y; bool viz[100100], seen[100100];
vector <pair <ll, ll> > v[100100];

void fall(int x){
	viz[x] = 1;
	seen[x] = 1;
	for(auto nod : v[x]){
		if(!seen[nod.st] && !viz[nod.st]){
			fall(nod.st);
		}
	}
}

void dfs(int x){
	viz[x] = 1;
	for(auto nod : v[x]){
		if(!viz[nod.st]){
			sums[nod.st] = max(sums[x] + nod.nd, nod.nd);
			if(g[nod.st] < sums[nod.st]) fall(nod.st);
			else dfs(nod.st);
		}
	}
}

int main(){
//	ifstream cin("tst.in");
	//ofstream out("tst.out");
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> g[i];
	for(int i = 1; i < n; i++){
		cin >> x >> y;
		v[x].pb(mp(i+1, y));
		v[i+1].pb(mp(x, y));
	}
	dfs(1);
	for(int i = 1; i <= n; i++) if(seen[i]) ans++;
	cout << ans;
//	for(int i = 1; i <= n; i++){
//		out << i << " -> ";
//		for(auto nod : v[i]) out << nod.st << ' ';
///		out << '\n';
//	}
	//for(int i = 1; i <= n; i++) cout << sums[i] << ' ';
	return 0;
}


#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

ll n, ans, sums[100100], g[100100], x, y; bool viz[100100], seen[100100];
vector <pair <ll, ll> > v[100100];

void fall(int x){
	viz[x] = 1;
	seen[x] = 1;
	for(auto nod : v[x]){
		if(!seen[nod.st] && !viz[nod.st]){
			fall(nod.st);
		}
	}
}

void dfs(int x){
	viz[x] = 1;
	for(auto nod : v[x]){
		if(!viz[nod.st]){
			sums[nod.st] = max(sums[x] + nod.nd, nod.nd);
			if(g[nod.st] < sums[nod.st]) fall(nod.st);
			else dfs(nod.st);
		}
	}
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> g[i];
	for(int i = 1; i < n; i++){
		cin >> x >> y;
		v[x].pb(mp(i+1, y));
		v[i+1].pb(mp(x, y));
	}
	dfs(1);
	for(int i = 1; i <= n; i++) if(seen[i]) ans++;
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

ll n, ans, sums[100100], g[100100], x, y; bool viz[100100], seen[100100];
vector <pair <ll, ll> > v[100100];

void fall(int x){
	viz[x] = 1;
	seen[x] = 1;
	for(auto nod : v[x]){
		if(!seen[nod.st] && !viz[nod.st]){
			fall(nod.st);
		}
	}
}

void dfs(int x){
	viz[x] = 1;
	for(auto nod : v[x]){
		if(!viz[nod.st]){
			sums[nod.st] = sums[x] + nod.nd;
			if(g[nod.st] < sums[nod.st]) fall(nod.st);
			else dfs(nod.st);
		}
	}
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> g[i];
	for(int i = 1; i < n; i++){
		cin >> x >> y;
		v[x].pb(mp(i+1, y));
		v[i+1].pb(mp(x, y));
	}
	dfs(1);
	for(int i = 1; i <= n; i++) if(seen[i]) ans++;
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
map<int,vector<int>> v,v1;
int vis[N],par[N],ps[N];
ll a[N],dist[N];
map<pair<int,int>,ll> mp;
void dfs(int u)
{
    vis[u]=1;
    if(u!=1)
    {
        dist[u]=dist[par[u]]+mp[{par[u],u}];

        if(ps[par[u]]==-1)
            ps[u]=-1;
        else{
            v1[u]=v1[par[u]];
            v1[u].push_back(par[u]);
            for(int i=0;i<v1[u].size();i++)
            {
                if(dist[u]-dist[v1[u][i]]>a[u])
                {
                    ps[u]=-1;
                    break;
                }
            }
        }
    }

    for(auto i : v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dist[1]=0;
    dfs(1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ps[i]==-1)
            ans++;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
vector<int> v[N],v1[N];
int vis[N],par[N],ps[N];
ll a[N],dist[N];
map<pair<int,int>,ll> mp;
void dfs(int u)
{
    vis[u]=1;
    if(u!=1)
    {
        dist[u]=dist[par[u]]+mp[{par[u],u}];
        v1[u]=v1[par[u]];
        v1[u].push_back(par[u]);
        if(ps[par[u]]==-1)
            ps[u]=-1;
        else{
            for(int i=0;i<v1[u].size();i++)
            {
                if(dist[u]-dist[v1[u][i]]>a[u])
                {
                    ps[u]=-1;
                    break;
                }
            }
        }
    }

    for(auto i : v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dist[1]=0;
    dfs(1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ps[i]==-1)
            ans++;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
vector<int> v[N];
ll vis[N],par[N],a[N],dist[N],DNode[N];
map<pair<int,int>,ll> mp;
vector<ll> trav;
void dfs(int u)
{
    vis[u]=1;
    trav.push_back(u);
    if(u!=1)
        dist[u]=dist[par[u]]+mp[{par[u],u}];
    DNode[u]=1;
    for(auto i : v[u])
    {
        if(!vis[i])
        {
            dfs(i);
            DNode[u]+=DNode[i];
        }
    }
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];

    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dfs(1);
    ll ans=0;
    for(int i=1;i<trav.size();i++)
    {
        int fl=0;
        for(int j=0;j<i;j++)
        {
            if(dist[i]-dist[j]>a[i])
            {
                fl=1;
                break;
            }
        }
        if(fl)
        {
            ans+=DNode[i];
            i+=DNode[i]-1;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
map<int,vector<int>> v,v1;
int vis[N],par[N],ps[N];
ll a[N],dist[N];
map<pair<int,int>,ll> mp;
void dfs(int u)
{
    vis[u]=1;
    if(u!=1)
    {
        dist[u]=dist[par[u]]+mp[{par[u],u}];
        v1[u]=v1[par[u]];
        v1[u].push_back(par[u]);
        if(ps[par[u]]==-1)
            ps[u]=-1;
        else{
            for(int i=0;i<v1[u].size();i++)
            {
                if(dist[u]-dist[v1[u][i]]>a[u])
                {
                    ps[u]=-1;
                    break;
                }
            }
        }
    }

    for(auto i : v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dist[1]=0;
    dfs(1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ps[i]==-1)
            ans++;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
vector<int> v[N],v1[N];
ll vis[N],par[N],a[N],dist[N],ps[N];
map<pair<int,int>,ll> mp;
vector<ll> trav;
void dfs(int u)
{
    vis[u]=1;
    trav.push_back(u);
    if(u!=1)
    {
        dist[u]=dist[par[u]]+mp[{par[u],u}];
        v1[u]=v1[par[u]];
        v1[u].push_back(par[u]);
        if(ps[par[u]]==-1)
            ps[u]=-1;
        else{
            for(int i=0;i<v1[u].size();i++)
            {
                if(dist[u]-dist[v1[u][i]]>a[u])
                {
                    ps[u]=-1;
                    break;
                }
            }
        }
    }

    for(auto i : v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dist[1]=0;
    dfs(1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ps[i]==-1)
            ans++;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
map<int,vector<int>> v;
int vis[N],par[N],ps[N];
ll a[N],dist[N];
map<pair<int,int>,ll> mp;
void dfs(int u)
{
    vis[u]=1;
    if(u!=1)
    {
        dist[u]=max(dist[par[u]]+mp[{par[u],u}],(ll)0);
        if(ps[par[u]]==-1)
            ps[u]=-1;
        else{
            if(dist[u]>a[u])
                ps[u]=-1;
        }
    }

    for(auto i : v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dist[1]=0;
    dfs(1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ps[i]==-1)
            ans++;
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#define ll long long int
#define N 100001
using namespace std;
map<int,vector<int>> v,v1;
int vis[N],par[N],ps[N];
ll a[N],dist[N];
map<pair<int,int>,ll> mp;
void dfs(int u)
{
    vis[u]=1;
    if(u!=1)
    {
        dist[u]=dist[par[u]]+mp[{par[u],u}];

        if(ps[par[u]]==-1)
            ps[u]=-1;
        else{
            v1[u]=v1[par[u]];
            v1[u].push_back(par[u]);
            for(int i=0;i<v1[u].size();i++)
            {
                if(dist[u]-dist[v1[u][i]]>a[u])
                {
                    ps[u]=-1;
                    break;
                }
            }
        }
    }

    for(auto i : v[u])
    {
        if(!vis[i])
            dfs(i);
    }
}
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=2;i<=n;i++)
    {
        ll p,c;cin>>p>>c;
        v[p].push_back(i);
        v[i].push_back(p);
        mp[{p,i}]=c;
        mp[{i,p}]=c;
        par[i]=p;
    }
    dist[1]=0;
    dfs(1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(ps[i]==-1)
            ans++;
    }
    cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define MAXNODES 100009
#define mod 1073741824

void kk ()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

//53 41 22 22 34 95 56 24

vector<vector<pair<int,int> > >v;
ll ans;
ll arr[100005];
void dfs (int node , int prnt, ll sum, bool found, int c , ll tempcost)
{

   if (sum>arr[node] || tempcost>arr[node])
   {
       found=true;
   }
   if (found)
        c++;
    for (int i=0;i<v[node].size();i++)
    {
        int child=v[node][i].first;
        ll cost=v[node][i].second;
        if (child!=prnt)
            dfs(child,node,sum+cost,found,c,cost);
    }
    if (v[node].size()==1)
    {
        ans+=c;
    }

}

int main()
{

    kk ();

    /*  freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);*/

    int n;
    cin>>n;
    v.resize(n+5);
    for (int i=1;i<=n;i++)
        cin>>arr[i];
    n--;
    for (int i=1;i<=n;i++)
    {
        int x,c;
        cin>>x>>c;
        v[i+1].push_back({x,c});
        v[x].push_back({i+1,c});
    }
    dfs(1,-1,0,0,0,0);
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define MAXNODES 100009
#define mod 1073741824

void kk ()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

vector<vector<pair<int,int> > >v;
ll ans;
ll arr[100005];
void dfs (int node , int prnt, ll sum, bool found, int c)
{

   if (sum>arr[node])
   {
       found=true;
   }
   if (found)
        c++;
    for (int i=0;i<v[node].size();i++)
    {
        int child=v[node][i].first;
        int cost=v[node][i].second;
        if (child!=prnt)
            dfs(child,node,sum+cost,found,c);
    }
    if (v[node].size()==1)
        ans+=c;
}

int main()
{

    kk ();

    /*  freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);*/

    int n;
    cin>>n;
    v.resize(n+5);
    for (int i=1;i<=n;i++)
        cin>>arr[i];
    n--;
    for (int i=1;i<=n;i++)
    {
        int x,c;
        cin>>x>>c;
        v[i+1].push_back({x,c});
        v[x].push_back({i+1,c});
    }
    dfs(1,-1,0,0,0);
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define MAXNODES 100009
#define mod 1073741824

void kk ()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

vector<vector<pair<int,int> > >v;
ll ans;
ll arr[100005];
bool vis[100005];
void dfs (int node , ll sum)
{

   if (sum>arr[node])
        return;
    vis[node]=true;
    for (int i=0;i<v[node].size();i++)
    {
        int child=v[node][i].first;
        ll cost=v[node][i].second;
        if (!vis[child])
            dfs(child,max(cost,sum+cost));
    }

}

int main()
{

    kk ();

    /*  freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);*/

    int n;
    cin>>n;
    v.resize(n+5);
    for (int i=1;i<=n;i++)
        cin>>arr[i];
    for (int i=2;i<=n;i++)
    {
        int x,c;
        cin>>x>>c;
        v[i].push_back({x,c});
        v[x].push_back({i,c});
    }
    dfs(1,0);
    for (int i=1;i<=n;i++)
        if (!vis[i])
        ans++;
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define MAXNODES 100009
#define mod 1073741824

void kk ()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

vector<vector<pair<int,int> > >v;
ll ans;
ll arr[100005];
void dfs (int node , int prnt, ll sum, bool found, int c)
{

   if (sum>arr[node])
   {
       found=true;
   }
   if (found)
        c++;
    for (int i=0;i<v[node].size();i++)
    {
        int child=v[node][i].first;
        ll cost=v[node][i].second;
        if (child!=prnt)
            dfs(child,node,sum+cost,found,c);
    }
    if (v[node].size()==1)
        ans+=c;
}

int main()
{

    kk ();

    /*  freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);*/

    int n;
    cin>>n;
    v.resize(n+5);
    for (int i=1;i<=n;i++)
        cin>>arr[i];
    n--;
    for (int i=1;i<=n;i++)
    {
        int x,c;
        cin>>x>>c;
        v[i+1].push_back({x,c});
        v[x].push_back({i+1,c});
    }
    dfs(1,-1,0,0,0);
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define MAXNODES 100009
#define mod 1073741824

void kk ()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

//53 41 22 22 34 95 56 24

vector<vector<pair<int,int> > >v;
ll ans;
ll arr[100005];
void dfs (int node , int prnt, ll sum, bool found,int c)
{

   if (sum>arr[node] )
   {
       found=true;
   }
   if (found)
        c++;
    for (int i=0;i<v[node].size();i++)
    {
        int child=v[node][i].first;
        ll cost=v[node][i].second;
        if (child!=prnt)
            dfs(child,node,max(cost,sum+cost),found,c);
    }
    if (v[node].size()==1)
    {
        ans+=c;
    }

}

int main()
{

    kk ();

    /*  freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);*/

    int n;
    cin>>n;
    v.resize(n+5);
    for (int i=1;i<=n;i++)
        cin>>arr[i];
    n--;
    for (int i=1;i<=n;i++)
    {
        int x,c;
        cin>>x>>c;
        v[i+1].push_back({x,c});
        v[x].push_back({i+1,c});
    }
    dfs(1,-1,0,0,0);
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define MAXNODES 100009
#define mod 1073741824

void kk ()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

//53 41 22 22 34 95 56 24

vector<vector<pair<int,int> > >v;
ll ans;
ll arr[100005];
void dfs (int node , int prnt, ll sum)
{

   if (sum>arr[node])
        ans++;
    for (int i=0;i<v[node].size();i++)
    {
        int child=v[node][i].first;
        ll cost=v[node][i].second;
        if (child!=prnt)
            dfs(child,node,max(cost,sum+cost));
    }

}

int main()
{

    kk ();

    /*  freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);*/

    int n;
    cin>>n;
    v.resize(n+5);
    for (int i=1;i<=n;i++)
        cin>>arr[i];
    n--;
    for (int i=1;i<=n;i++)
    {
        int x,c;
        cin>>x>>c;
        v[i+1].push_back({x,c});
        v[x].push_back({i+1,c});
    }
    dfs(1,-1,0);
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+5;

vector<pii > g[maxn];
vi cost(maxn);

ll dfs_dp(int v, int p, ll sum)
{
    ll res(1);
    if(sum > cost[v]) return 0;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        res += dfs_dp(to._f, v, sum + to._s);
    }
    return res;
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    cout << n - dfs_dp(1,0,0);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+5;

vector<pii > g[maxn];
ll dp[maxn];
ll ans;
vi cost(maxn);

void dfs_dp(int v, int p, ll sum)
{
    dp[v] = sum;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_dp(to._f, v, sum + to._s);
    }
}

ll destroy_vertex(int v, int p)
{
    ll res(1);
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        res += destroy_vertex(to._f, v);
    }
    return res;
}

void dfs_ans(int v, int p, ll ms)
{
    if(p == 1)
    {
        if(dp[v] - 0  > cost[v])
        {
            ans += destroy_vertex(v, p);
            return;
        }
    }
    ms = min(ms, dp[v]);
    if(dp[v] - ms  > cost[v])
    {
        ans += destroy_vertex(v, p);
        return;
    }
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_ans(to._f, v, ms);
    }
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    dfs_dp(1,0,0);
    REP(i, 0, g[1].size())
    {
        pii to = g[1][i];
        dfs_ans(to._f, 1ll, cost[to._f]);
    }
    cout << ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+5;

vector<pii > g[maxn];
ll dp[maxn];
ll ans;
vi cost(maxn);

void dfs_dp(int v, int p, ll sum)
{
    dp[v] =  sum;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_dp(to._f, v, sum + to._s);
    }
}

int destroy_vertex(int v, int p)
{
    ll ans(1);
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        ans += destroy_vertex(to._f, v);
    }
    return ans;
}

void dfs_ans(int v, int p, ll ms)
{
    ms = min(ms, dp[v]);
    if(dp[v] - ms  > cost[v])
    {
        ans += destroy_vertex(v, p);
        return;
    }
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_ans(to._f, v, ms);
    }
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    dfs_dp(1,0,0);
    REP(i, 0, g[1].size())
    {
        pii to = g[1][i];
        dfs_ans(to._f, 1ll, cost[to._f]);
    }
    cout << ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+5;

vector<pii > g[maxn];
ll dp[maxn];
ll ans;
vi cost(maxn);

void dfs_dp(int v, int p, ll sum)
{
    dp[v] = sum;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_dp(to._f, v, sum + to._s);
    }
}

ll destroy_vertex(int v, int p)
{
    ll ans(1);
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        ans += destroy_vertex(to._f, v);
    }
    return ans;
}

void dfs_ans(int v, int p, ll ms)
{
    ms = min(ms, dp[v]);
    if(dp[v] - ms  > cost[v])
    {
        ans += destroy_vertex(v, p);
        return;
    }
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_ans(to._f, v, ms);
    }
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    dfs_dp(1,0,0);
    REP(i, 0, g[1].size())
    {
        pii to = g[1][i];
        dfs_ans(to._f, 1ll, 0);
    }
    cout << ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+4;

vector<pii > g[maxn];
ll dp[maxn];
ll ans;
vi cost(maxn);

void dfs_dp(int v, int p, ll sum)
{
    dp[v] = sum;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_dp(to._f, v, sum + to._s);
    }
}

ll destroy_vertex(int v, int p)
{
    ll ans(1);
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        ans += destroy_vertex(to._f, v);
    }
    return ans;
}

void dfs_ans(int v, int p, ll ms)
{
    ms = min(ms, dp[v]);
    if(dp[v] - ms  > cost[v])
    {
        ans += destroy_vertex(v, p);
        return;
    }
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_ans(to._f, v, ms);
    }
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    dfs_dp(1,0,0);
    REP(i, 0, g[1].size())
    {
        pii to = g[1][i];
        dfs_ans(to._f, 1ll, 0);
    }
    cout << ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+5;

vector<pii > g[maxn];
ll dp[maxn];
ll ans;
vi cost(maxn);

void dfs_dp(int v, int p, ll sum)
{
    dp[v] = sum;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_dp(to._f, v, sum + to._s);
    }
}

ll destroy_vertex(int v, int p)
{
    ll ans(1);
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        ans += destroy_vertex(to._f, v);
    }
    return ans;
}

void dfs_ans(int v, int p, ll ms)
{
    ms = min(ms, dp[v]);
    cout << ms << " " << dp[v] << endl;
    if(dp[v] - ms  > cost[v])
    {
        ans += destroy_vertex(v, p);
        return;
    }
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        dfs_ans(to._f, v, ms);
    }
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    dfs_dp(1,0,0);
    REP(i, 0, g[1].size())
    {
        pii to = g[1][i];
        dfs_ans(to._f, 1ll, 0);
    }
    cout << ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define all(t) t.begin(),t.end()
#define cen cout<<endl
#define _f first
#define _s second
#define REP(i, a, b) for(long long i = (a); i < (long long)(b); i++)
#define REPN(i, a, b) for(long long i = (a); i <= (long long)(b); i++)
#define vi vector<int>
#define pii pair<int,int>

#define INFL LLONG_MAX
#define INFI INT_MAX

typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;

#define file "name_of_file"
#define read1

const int maxn = 1e5+5;

vector<pii > g[maxn];
vi cost(maxn);

ll dfs_dp(int v, int p, ll sum, ll mn)
{
    ll res(1);
    mn = min(sum, mn);
    if(sum - mn > cost[v]) return 0;
    REP(i, 0, g[v].size())
    {
        pii to = g[v][i];
        if(to._f == p) continue;
        res += dfs_dp(to._f, v, sum + to._s, mn);
    }
    return res;
}

void solve()
{
    int n, t, c;
    cin >> n;
    REPN(i, 1, n)
    {
        cin >> cost[i];
    }
    REPN(i, 1, n-1)
    {
        cin >> t >> c;
        g[t].pb(mp(i+1,c));
        g[i+1].pb(mp(t, c));
    }
    cout << n - dfs_dp(1,0,0,0);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    #ifdef solved
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    #ifdef read
    freopen(file".in", "r", stdin);
    freopen(file".out", "w", stdout);
    #endif

    int t = 1;
    while(t--)
        solve();

    return 0;
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class BB
{
 static class cell {
     int j,val;

        public cell( int j, int val) {

            this.j = j;
            this.val = val;
        }

 }
   static class item {
       ArrayList<cell>ar=new ArrayList<cell>();
        int value;
        boolean visited=false;

        public item(int value) {
            this.value = value;
        }

    }
   static int n;
   static item[]a;
public static void main(String[] args)
{

    FastScanner sc= new FastScanner(System.in);

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

    }
    for (int i = 0; i < n-1; i++) {
        int x1=sc.nextInt()-1;
        int x2=sc.nextInt();
        a[i+1].ar.add(new cell(x1, x2));
        a[x1].ar.add(new cell(i+1, x2));

    }

    System.out.println(dfs(0, 0));

}

static int  dfs(int i,int sum){

    if(a[i].visited)
        return 0;
        else
        a[i].visited=true;

   // System.out.println(i);

        if(a[i].value<sum)
        {
           // System.out.println("delete: "+i+" add:"+subTreeSum(i));

           return subTreeSum(i);
        }

    int res=0;
    for (int j = 0; j < a[i].ar.size(); j++) {
        if(!a[a[i].ar.get(j).j].visited)
        {

            res+= dfs(a[i].ar.get(j).j, a[i].ar.get(j).val+sum);
          //  System.out.println("res= "+res);
        }
    }

        return res;
}

static int subTreeSum(int i){

    if(a[i].ar.size()==1)
        return 1;
    else
    {
        a[i].visited=true;
        int res=0;
         for (int j = 0; j < a[i].ar.size(); j++) {

            if(!a[a[i].ar.get(j).j].visited)
            res+=1+ subTreeSum(a[i].ar.get(j).j);

    }
        return res;

    }
}

static 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());
		}
	}

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class BB
{
 static class cell {
     int j,val;

        public cell( int j, int val) {

            this.j = j;
            this.val = val;
        }

 }
   static class item {
       ArrayList<cell>ar=new ArrayList<cell>();
        int value;
        boolean visited=false;

        public item(int value) {
            this.value = value;
        }

    }
   static int n;
   static item[]a;
public static void main(String[] args)
{

    FastScanner sc= new FastScanner(System.in);

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

    }
    for (int i = 0; i < n-1; i++) {
        int x1=sc.nextInt()-1;
        int x2=sc.nextInt();
        a[i+1].ar.add(new cell(x1, x2));
        a[x1].ar.add(new cell(i+1, x2));

    }

    System.out.println(dfs(0, 0));

}

static int  dfs(int i,int sum){

    if(a[i].visited)
        return 0;
        else
        a[i].visited=true;

   // System.out.println(i);

        if(a[i].value<sum)
        {
           // System.out.println("delete: "+i+" add:"+subTreeSum(i));

           return subTreeSum(i);
        }

    int res=0;
    for (int j = 0; j < a[i].ar.size(); j++) {
        if(!a[a[i].ar.get(j).j].visited)
        {

            res+= dfs(a[i].ar.get(j).j, a[i].ar.get(j).val);
          //  System.out.println("res= "+res);
        }
    }

        return res;
}

static int subTreeSum(int i){

    if(a[i].ar.size()==1)
        return 1;
    else
    {
        a[i].visited=true;
        int res=0;
         for (int j = 0; j < a[i].ar.size(); j++) {

            if(!a[a[i].ar.get(j).j].visited)
            res+=1+ subTreeSum(a[i].ar.get(j).j);

    }
        return res;

    }
}

static 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());
		}
	}

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class BB
{
 static class cell {
     int j,val;

        public cell( int j, int val) {

            this.j = j;
            this.val = val;
        }

 }
   static class item {
       ArrayList<cell>ar=new ArrayList<cell>();
        int value;
        boolean visited=false;

        public item(int value) {
            this.value = value;
        }

    }
   static int n;
   static item[]a;
public static void main(String[] args)
{

    FastScanner sc= new FastScanner(System.in);

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

    }
    for (int i = 0; i < n-1; i++) {
        int x1=sc.nextInt()-1;
        int x2=sc.nextInt();
        a[i+1].ar.add(new cell(x1, x2));
        a[x1].ar.add(new cell(i+1, x2));

    }

    System.out.println(dfs(0, 0));

}

static int  dfs(int i,int sum){

    if(a[i].visited)
        return 0;
        else
        a[i].visited=true;

   // System.out.println(i);

        if(a[i].value<sum)
        {
           // System.out.println("delete: "+i+" add:"+subTreeSum(i));

           return subTreeSum(i);
        }

    int res=0;
    for (int j = 0; j < a[i].ar.size(); j++) {
        if(!a[a[i].ar.get(j).j].visited)
        {

            res+= dfs(a[i].ar.get(j).j,Math.max(sum+ a[i].ar.get(j).val,a[i].ar.get(j).val));
          //  System.out.println("res= "+res);
        }
    }

        return res;
}

static int subTreeSum(int i){

    if(a[i].ar.size()==1)
        return 1;
    else
    {
        a[i].visited=true;
        int res=0;
         for (int j = 0; j < a[i].ar.size(); j++) {

            if(!a[a[i].ar.get(j).j].visited)
            res+=1+ subTreeSum(a[i].ar.get(j).j);

    }
        return res;

    }
}

static 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());
		}
	}

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;

public class BB
{
 static class cell {
     int j,val;

        public cell( int j, int val) {

            this.j = j;
            this.val = val;
        }

 }
   static class item {
       ArrayList<cell>ar=new ArrayList<cell>();
        int value;
        boolean visited=false;

        public item(int value) {
            this.value = value;
        }

    }
   static int n;
   static item[]a;
public static void main(String[] args)
{

    FastScanner sc= new FastScanner(System.in);

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

    }
    for (int i = 0; i < n-1; i++) {
        int x1=sc.nextInt()-1;
        int x2=sc.nextInt();
        a[i+1].ar.add(new cell(x1, x2));
        a[x1].ar.add(new cell(i+1, x2));

    }

    System.out.println(n-dfs(0, 0));

}

static int  dfs(int i,int sum){

    if(a[i].visited)
        return 0;
        else
        a[i].visited=true;

   // System.out.println(i);

        if(a[i].value<sum)
        {
           // System.out.println("delete: "+i+" add:"+subTreeSum(i));

           return 0;
        }

    int res=1;
    for (int j = 0; j < a[i].ar.size(); j++) {
        if(!a[a[i].ar.get(j).j].visited)
        {

            res+= dfs(a[i].ar.get(j).j,Math.max(sum+ a[i].ar.get(j).val,a[i].ar.get(j).val));
          //  System.out.println("res= "+res);
        }
    }

        return res;
}

static int subTreeSum(int i){

    if(a[i].ar.size()==1)
        return 1;
    else
    {
        a[i].visited=true;
        int res=0;
         for (int j = 0; j < a[i].ar.size(); j++) {

            if(!a[a[i].ar.get(j).j].visited)
            res+=1+ subTreeSum(a[i].ar.get(j).j);

    }
        return res;

    }
}

static 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());
		}
	}

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

import java.util.StringTokenizer;

public class Codeforces358 {

	static boolean visited[];
	static boolean sad[];
	static int va[];
	static int count;
	static ArrayList<Vertex> l[];
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MyScanner358 sc=new MyScanner358();
		int n=sc.nextInt();
		va=new int[n];
		visited=new boolean[n];
		sad=new boolean[n];

		int i;
		for(i=0;i<n;i++)
		{
			va[i]=sc.nextInt();

		}
		l=  new ArrayList[n];
		for(i=0;i<n;i++)
		{
			l[i]=new ArrayList<Vertex>();
		}

		for(i=1;i<n;i++)
		{
			int p=sc.nextInt()-1;
			int c=sc.nextInt();
			l[i].add(new Vertex(p,c));
			l[p].add(new Vertex(i,c));
		}

		int root=0;
		for(i=0;i<n;i++)
		{
			if(l[i].size()>=2)
			{

				root=i;
				break;
			}
		}
	//	System.out.println(root);
		dfs(root,0,l[root]);
		 count=0;

		for(i=0;i<n;i++)
		{
			if(sad[i])
			{
				mdfs(i,l[i]);

			}
		}

		System.out.println(count);

	}

	static void dfs(int v,long dist,ArrayList<Vertex> li)
	{
		visited[v]=true;
		if(dist<0)
			dist=0;
		for(Vertex d: li)
		{
			//System.out.println("Checking "+d.p);
			if(!visited[d.p])
			{
				//System.out.println("Entered "+d.p);
				if((dist+d.c)>va[d.p])
				{
					sad[d.p]=true;

					//System.out.println("Marked "+d.p);
				}
				else
				{
					dfs(d.p,dist+d.c,l[d.p]);
				}
			}
		}
	}

		static void mdfs(int v,ArrayList<Vertex> li)
		{
			visited[v]=true;
			count++;
			for(Vertex d: li)
			{
				if(!visited[d.p])
				{
					mdfs(d.p,l[d.p]);
				}
			}

	}
	static class Vertex
	{
		int p;
		int c;
		Vertex(int p,int c)
		{
			this.p=p;
			this.c=c;

		}
	}
}

class MyScanner358
{
	BufferedReader br;
	StringTokenizer st;
	MyScanner358()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	String next()
	{

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

	}
	int nextInt()
	{
		return Integer.parseInt(next());
	}
	long nextLong()
	{
		return Long.parseLong(next());
	}
	double nextDouble()
	{
		return Double.parseDouble(next());
	}
	String nextLine()
	{
		String str="";
		try
		{
			str=br.readLine();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return str;

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

import java.util.StringTokenizer;

public class Codeforces358 {

	static boolean visited[];
	static boolean sad[];
	static int va[];
	static int count;
	static ArrayList<Vertex> l[];
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MyScanner358 sc=new MyScanner358();
		int n=sc.nextInt();
		va=new int[n];
		visited=new boolean[n];
		sad=new boolean[n];

		int i;
		for(i=0;i<n;i++)
		{
			va[i]=sc.nextInt();

		}
		l=  new ArrayList[n];
		for(i=0;i<n;i++)
		{
			l[i]=new ArrayList<Vertex>();
		}

		for(i=1;i<n;i++)
		{
			int p=sc.nextInt()-1;
			int c=sc.nextInt();
			l[i].add(new Vertex(p,c));
			l[p].add(new Vertex(i,c));
		}

		int root=0;

		dfs(root,0,l[root]);
		 count=0;

		for(i=0;i<n;i++)
		{
			if(sad[i])
			{
				mdfs(i,l[i]);

			}
		}

		System.out.println(count);

	}

	static void dfs(int v,long dist,ArrayList<Vertex> li)
	{
		visited[v]=true;
		if(dist<0)
			dist=0;
		for(Vertex d: li)
		{
			System.out.println("Checking "+d.p);
			if(!visited[d.p])
			{
				System.out.println("Entered "+d.p);
				if((dist+d.c)>va[d.p])
				{
					sad[d.p]=true;

					System.out.println("Marked "+d.p);
				}
				else
				{
					dfs(d.p,dist+d.c,l[d.p]);
				}
			}
		}
	}

		static void mdfs(int v,ArrayList<Vertex> li)
		{
			visited[v]=true;
			count++;
			for(Vertex d: li)
			{
				if(!visited[d.p])
				{
					mdfs(d.p,l[d.p]);
				}
			}

	}
	static class Vertex
	{
		int p;
		int c;
		Vertex(int p,int c)
		{
			this.p=p;
			this.c=c;

		}
	}
}

class MyScanner358
{
	BufferedReader br;
	StringTokenizer st;
	MyScanner358()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	String next()
	{

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

	}
	int nextInt()
	{
		return Integer.parseInt(next());
	}
	long nextLong()
	{
		return Long.parseLong(next());
	}
	double nextDouble()
	{
		return Double.parseDouble(next());
	}
	String nextLine()
	{
		String str="";
		try
		{
			str=br.readLine();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return str;

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

import java.util.StringTokenizer;

public class Codeforces358 {

	static boolean visited[];
	static boolean sad[];
	static int va[];
	static int count;
	static ArrayList<Vertex> l[];
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MyScanner358 sc=new MyScanner358();
		int n=sc.nextInt();
		va=new int[n];
		visited=new boolean[n];
		sad=new boolean[n];

		int i;
		for(i=0;i<n;i++)
		{
			va[i]=sc.nextInt();

		}
		l=  new ArrayList[n];
		for(i=0;i<n;i++)
		{
			l[i]=new ArrayList<Vertex>();
		}

		for(i=1;i<n;i++)
		{
			int p=sc.nextInt()-1;
			int c=sc.nextInt();
			l[i].add(new Vertex(p,c));
			l[p].add(new Vertex(i,c));
		}

		int root=0;

		dfs(root,0,l[root]);
		 count=0;

		for(i=0;i<n;i++)
		{
			if(sad[i])
			{
				mdfs(i,l[i]);

			}
		}

		System.out.println(count);

	}

	static void dfs(int v,long dist,ArrayList<Vertex> li)
	{
		visited[v]=true;
		if(dist<0)
			dist=0;
		for(Vertex d: li)
		{
			//System.out.println("Checking "+d.p);
			if(!visited[d.p])
			{
				//System.out.println("Entered "+d.p);
				if((dist+d.c)>va[d.p])
				{
					sad[d.p]=true;

					//System.out.println("Marked "+d.p);
				}
				else
				{
					dfs(d.p,dist+d.c,l[d.p]);
				}
			}
		}
	}

		static void mdfs(int v,ArrayList<Vertex> li)
		{
			visited[v]=true;
			count++;
			for(Vertex d: li)
			{
				if(!visited[d.p])
				{
					mdfs(d.p,l[d.p]);
				}
			}

	}
	static class Vertex
	{
		int p;
		int c;
		Vertex(int p,int c)
		{
			this.p=p;
			this.c=c;

		}
	}
}

class MyScanner358
{
	BufferedReader br;
	StringTokenizer st;
	MyScanner358()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	String next()
	{

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

	}
	int nextInt()
	{
		return Integer.parseInt(next());
	}
	long nextLong()
	{
		return Long.parseLong(next());
	}
	double nextDouble()
	{
		return Double.parseDouble(next());
	}
	String nextLine()
	{
		String str="";
		try
		{
			str=br.readLine();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return str;

	}
}


import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.NavigableMap;
import java.util.TreeMap;

public class C {

	private static int[] dfs(List<List<int[]>> tree,
			int v,
			int p,
			int[] a,
			long path,
			NavigableMap<Long, Integer> map) {
		// check if this is vertex makes someone sad
		Integer c = map.get(path);
		if (c == null) {
			c = 1;
		} else {
			c = c + 1;
		}
		map.put(path, c);
		int children = 0;
		int removed = 0;
		for (int[] b : tree.get(v)) {
			int w = b[0];
			int l = b[1];
			if (w == p) {
				continue;
			}
			final int[] r = dfs(tree, w, v, a, path + l, map);
			children += r[0];
			removed += r[1];
		}
		final int[] res;
		if (map.lowerKey(path - a[v]) != null) {
			res = new int[] {children + 1, children + 1};
		} else {
			res = new int[] {children + 1, removed};
		}
		if (c == 1) {
			map.remove(path);
		} else {
			map.put(path, c - 1);
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		try (FastScanner fs = new FastScanner()) {
			final int n = fs.nextInt();
			final int[] a = new int[n + 1];
			for (int i = 1; i <= n; ++i) {
				a[i] = fs.nextInt();
			}
			final List<List<int[]>> tree = new ArrayList<>();
			for (int i = 0; i <= n; ++i) {
				tree.add(new ArrayList<int[]>());
			}
			for (int i = 1; i <= n - 1; ++i) {
				final int p = fs.nextInt();
				final int c = fs.nextInt();
				tree.get(i + 1).add(new int[] {p, c});
				tree.get(p).add(new int[]{i + 1, c});
			}
			final int[] res = dfs(tree, 1, -1, a, 0, new TreeMap<Long, Integer>());
			System.out.println(res[1]);
		}
	}

	private static class FastScanner implements Closeable {
		private final BufferedReader reader;
		private String[] tokens;
		private int next;

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

		String next() throws IOException {
			if (tokens == null || tokens.length == next) {
				tokens = reader.readLine().split(" ");
				next = 0;
			}
			return tokens[next++];
		}

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

		public void close() throws IOException {
			reader.close();
		}
	}
}


import java.util.*;
public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
    }
	private static long countNodes(List<List<Node>> g, Node from) {
		int sum = 1;
		List<Node> nodes = g.get(from.data);
		for(Node n : nodes) {
			sum += countNodes(g, n);
		}
		return sum;
}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
    }
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
	private static class Node {
		int data;
		int c;

		Node(int data, int c) {
			this.data = data;
			this.c = c;
		}
	}

	private static long dfs(List<List<Node>> g, Node from) {
		if (from == null) {
			return 0;
		}
		int sum = 0;
		List<Node> nodes = g.get(from.data);
		for (Node node : nodes) {
			sum += dfs(g, node);
		}
		return sum + 1;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        List<List<Node>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
        	g.add(new ArrayList<>());
        }
        for (int i = 0 ; i < n - 1; i++) {
        	int p = sc.nextInt() - 1;
        	int c = sc.nextInt();
        	g.get(p).add(new Node(i + 1, c));
        }
        int sum = 0;
        Queue<Node> queue = new LinkedList<>();
        queue.offer(new Node(0, 0));
        while (!queue.isEmpty()) {
        	Node v = queue.poll();
        	List<Node> nodes = g.get(v.data);
        	for (Node node : nodes) {
        		if (node.c + v.c > a[node.data]) {
        			sum += dfs(g, node);
        		} else {
        			queue.offer(new Node(node.data, node.c + v.c));
        		}
        	}
        }
        System.out.println(sum);
    }
}


import java.util.*;
public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
	}

	private static long countNodes(List<List<Node>> g, Node from) {
		int sum = 1;
		List<Node> nodes = g.get(from.data);
		for(Node n : nodes) {
			sum += countNodes(g, n);
		}
		return sum;
	}

	private static long dfs(List<List<Node>> g, int from, long minDist, int[] a, long curDist) {
		long sum = 0;
		List<Node> nodes = g.get(from);
		for(Node n : nodes) {
			long dist = minDist == Long.MAX_VALUE ? curDist + n.c : curDist + n.c - minDist;
			if (dist > a[n.data]) {
				sum += countNodes(g, n);
			} else {
				sum += dfs(g, n.data, Math.min(minDist, curDist + n.c), a, curDist + n.c);
			}
		}
		return sum;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        List<List<Node>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
        	g.add(new ArrayList<Node>());
        }
        for (int i = 0 ; i < n - 1; i++) {
        	int p = sc.nextInt() - 1;
        	long c = sc.nextLong();
        	g.get(p).add(new Node(i + 1, c));
        }
        System.out.println((long)dfs(g, 0, Long.MAX_VALUE, a, 0));
    }
}


import java.util.*;
public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
    }
}


import java.util.*;
public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
    }
}


import java.util.*;
public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
    }
	private static long countNodes(List<List<Node>> g, Node from) {
		int sum = 1;
		List<Node> nodes = g.get(from.data);
		for(Node n : nodes) {
			sum += countNodes(g, n);
		}
		return sum;
}

	private static long dfs(List<List<Node>> g, int from, long minDist, int[] a, long curDist) {
		long sum = 0;
		List<Node> nodes = g.get(from);
		for(Node n : nodes) {
			long dist = minDist == Long.MAX_VALUE ? curDist + n.c : curDist + n.c - minDist;
			if (dist > a[n.data]) {
				sum += countNodes(g, n);
			} else {
				sum += dfs(g, n.data, Math.min(minDist, curDist + n.c), a, curDist + n.c);
			}
		}
		return sum;
}

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
    }
}


import java.util.*;
public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
	}

	private static long countNodes(List<List<Node>> g, Node from) {
		int sum = 1;
		List<Node> nodes = g.get(from.data);
		for(Node n : nodes) {
			sum += countNodes(g, n);
		}
		return sum;
	}

	private static long dfs(List<List<Node>> g, int from, long minDist, int[] a, long curDist) {
		long sum = 0;
		List<Node> nodes = g.get(from);
		for(Node n : nodes) {
			long dist = minDist == Long.MAX_VALUE ? curDist + n.c : curDist + n.c - minDist;
			if (dist > a[n.data]) {
				sum += countNodes(g, n);
			} else {
				sum += dfs(g, n.data, Math.min(minDist, curDist + n.c), a, curDist + n.c);
			}
		}
		return sum;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        List<List<Node>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
        	g.add(new ArrayList<>());
        }
        for (int i = 0 ; i < n - 1; i++) {
        	int p = sc.nextInt() - 1;
        	long c = sc.nextLong();
        	g.get(p).add(new Node(i + 1, c));
        }
        System.out.println((long)dfs(g, 0, Long.MAX_VALUE, a, 0));
    }
}


import java.util.*;
public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
	}

	private static void dfs(List<List<Node>> g, int v, long dist, int prev, boolean[] used, boolean[] deleted, int[] a) {
		if (used[v]) {
			return;
		}
		used[v] = true;
		deleted[v] = deleted[prev] || dist > a[v];
		List<Node> nodes = g.get(v);
		for(Node n : nodes) {
			if (!used[n.data]) {
				dfs(g, n.data, Math.max(dist + n.c, n.c), v, used, deleted, a);
			}
		}
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        List<List<Node>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
        	g.add(new ArrayList<Node>());
        }
        for (int i = 0 ; i < n - 1; i++) {
        	int p = sc.nextInt() - 1;
        	long c = sc.nextLong();
        	g.get(p).add(new Node(i + 1, c));
        	g.get(i + 1).add(new Node(p, c));
        }
        boolean[] used = new boolean[n];
        boolean[] deleted = new boolean[n];

        dfs(g, 0, 0, 0, used, deleted, a);
        int sum = 0;
        for (int i = 0; i < n; i++) {
        	if (deleted[i]) {
        		sum++;
        	}
        }
        System.out.println(sum);
    }
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
	}

	private static long countNodes(List<List<Node>> g, Node from) {
		int sum = 1;
		List<Node> nodes = g.get(from.data);
		for(Node n : nodes) {
			sum += countNodes(g, n);
		}
		return sum;
	}

	private static long dfs(List<List<Node>> g, int from, long minDist, int[] a, long curDist) {
		long sum = 0;
		List<Node> nodes = g.get(from);
		for(Node n : nodes) {
			long dist = minDist == Long.MAX_VALUE ? curDist + n.c : curDist + n.c - minDist;
			if (dist > a[n.data]) {
				sum += countNodes(g, n);
			} else {
				sum += dfs(g, n.data, Math.min(minDist, curDist + n.c), a, curDist + n.c);
			}
		}
		return sum;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        List<List<Node>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
        	g.add(new ArrayList<>());
        }
        for (int i = 0 ; i < n - 1; i++) {
        	int p = sc.nextInt() - 1;
        	long c = sc.nextLong();
        	g.get(p).add(new Node(i + 1, c));
        }
        System.out.println(dfs(g, 0, Long.MAX_VALUE, a, 0));
    }
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
	private static class Node {
		int data;
		long c;

		Node(int data, long c) {
			this.data = data;
			this.c = c;
		}
	}

	private static long countNodes(List<List<Node>> g, Node from) {
		int sum = 1;
		List<Node> nodes = g.get(from.data);
		for(Node n : nodes) {
			sum += countNodes(g, n);
		}
		return sum;
	}

	private static long dfs(List<List<Node>> g, int from, long minDist, int[] a, long curDist) {
		long sum = 0;
		List<Node> nodes = g.get(from);
		for(Node n : nodes) {
			long dist = minDist == Long.MAX_VALUE ? curDist + n.c : curDist + n.c - minDist;
			if (dist > a[n.data]) {
				sum += countNodes(g, n);
			} else {
				sum += dfs(g, n.data, Math.min(minDist, curDist + n.c), a, curDist + n.c);
			}
		}
		return sum;
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextInt();
        }
        List<List<Node>> g = new ArrayList<>();
        for (int i = 0; i < n; i++) {
        	g.add(new ArrayList<>());
        }
        for (int i = 0 ; i < n - 1; i++) {
        	int p = sc.nextInt() - 1;
        	long c = sc.nextLong();
        	g.get(p).add(new Node(i + 1, c));
        }
        System.out.println((long)dfs(g, 0, Long.MAX_VALUE, a, 0));
    }
}


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

public class CF682C{

	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	static int ans = 1;
	private static class Edge{
		int to,w;
		Edge(int a,int b){
			to =a;
			w = b;
		}
	}
	private static class Node{
		int index = -1;
		ArrayList<Edge> edge = new ArrayList<Edge>();
		Node(int ind){
			index = ind;
		}

	}

	private static void dfs(boolean is,int cur,int par,int till){
		for (Edge x : graph[cur].edge) {
			if(x.to != par){
//				pw.println(is + " " + ans + " " + cur + " " + par);
//				pw.println("asd " + is  + " " + cur + " " + a[x.to] + " " + till + " " + x.w);
				if(is && a[x.to] >= till+x.w){
					ans++;
					dfs(true,x.to,cur,till+x.w);
				}
				else{
					dfs(false,x.to,cur,till+x.w);
				}
			}
		}
	}
	private static int[] a;
	private static Node[] graph;
	private static void soln(){
		int n = nextInt();
		a = new int[n+1];
		graph = new Node[n+1];
		for (int i=1; i<=n; i++) {
			graph[i] = new Node(i);
			a[i] = nextInt();
		}
		for (int i=2; i<=n; i++) {
			int p = nextInt();
			int w = nextInt();
			graph[i].edge.add(new Edge(p,w));
			graph[p].edge.add(new Edge(i,w));
		}

		dfs(true,1,0,0);
		pw.println(n-ans);
	}

	public static void main(String[] args){
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods

	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

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

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static 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++];
	}

	private static int nextInt() {
		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;
	}

	private static long nextLong() {
		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;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

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

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

}


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

public class CF682C{

	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	static int ans = 1;
	private static class Edge{
		int to,w;
		Edge(int a,int b){
			to =a;
			w = b;
		}
	}
	private static class Node{
		int index = -1;
		ArrayList<Edge> edge = new ArrayList<Edge>();
		Node(int ind){
			index = ind;
		}

	}

	private static void dfs(boolean is,int cur,int par,int till){
		for (Edge x : graph[cur].edge) {
			if(x.to != par){
//				pw.println(is + " " + ans + " " + cur + " " + par);
//				pw.println("asd " + is  + " " + cur + " " + a[x.to] + " " + till + " " + x.w);
				if(is && a[x.to] >= till+x.w){
					ans++;
					dfs(true,x.to,cur,till+x.w);
				}
				else{
					dfs(false,x.to,cur,till+x.w);
				}
			}
		}
	}
	private static int[] a;
	private static Node[] graph;
	private static void soln(){
		int n = nextInt();
		a = new int[n+1];
		graph = new Node[n+1];
		for (int i=1; i<=n; i++) {
			graph[i] = new Node(i);
			a[i] = nextInt();
		}
		for (int i=2; i<=9; i++) {
			int p = nextInt();
			int w = nextInt();
			graph[i].edge.add(new Edge(p,w));
			graph[p].edge.add(new Edge(i,w));
		}

		dfs(true,1,0,0);
		pw.println(n-ans);
	}

	public static void main(String[] args){
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods

	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

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

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static 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++];
	}

	private static int nextInt() {
		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;
	}

	private static long nextLong() {
		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;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

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

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

}


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

public class CF682C{

	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	static int ans = 1;
	private static class Edge{
		int to,w;
		Edge(int a,int b){
			to =a;
			w = b;
		}
	}
	private static class Node{
		int index = -1;
		ArrayList<Edge> edge = new ArrayList<Edge>();
		Node(int ind){
			index = ind;
		}

	}

	private static void dfs(boolean is,int cur,int par,int till){
		for (Edge x : graph[cur].edge) {
			if(x.to != par){
//				pw.println(is + " " + ans + " " + cur + " " + par);
//				pw.println("asd " + is  + " " + cur + " " + a[x.to] + " " + till + " " + x.w);
				if(is && a[x.to] >= till+x.w){
					ans++;
					dfs(true,x.to,cur,Math.max(till+x.w,0));
				}
				else{
					dfs(false,x.to,cur,Math.max(till+x.w,0));
				}
			}
		}
	}
	private static int[] a;
	private static Node[] graph;
	private static void soln(){
		int n = nextInt();
		a = new int[n+1];
		graph = new Node[n+1];
		for (int i=1; i<=n; i++) {
			graph[i] = new Node(i);
			a[i] = nextInt();
		}
		for (int i=2; i<=n; i++) {
			int p = nextInt();
			int w = nextInt();
			graph[i].edge.add(new Edge(p,w));
			graph[p].edge.add(new Edge(i,w));
		}

		dfs(true,1,0,0);
		pw.println(n-ans);
	}

	public static void main(String[] args){
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}

	// To Get Input
	// Some Buffer Methods

	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}

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

	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private static 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++];
	}

	private static int nextInt() {
		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;
	}

	private static long nextLong() {
		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;
	}

	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr){
		for (int i=0; i<arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

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

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

}


import java.util.*;

public class AlyonaTree {

	static Leaf [] leaves ;

	public static void main(String[]args){
		Scanner scan = new Scanner (System.in);
		int numbLeaves = scan.nextInt();
		leaves = new Leaf [numbLeaves];
		for(int i=0; i<numbLeaves; i++)
		{
			leaves[i] = new Leaf(scan.nextInt());
		}
		for(int i=0; i<numbLeaves-1; i++)
		{
			int to = scan.nextInt()-1;
			int cost = scan.nextInt();
			leaves[i+1].to.add(leaves[to]);
			leaves[i+1].costs.put(leaves[to], cost);
			leaves[to].to.add(leaves[i+1]);
			leaves[to].costs.put(leaves[i+1], cost);
		}

		int result = removeIt(leaves[0], 0, null, false);
		System.out.println(result);

	}

	static int removeIt (Leaf start, int cost, ListIterator <Leaf> iterAbove, boolean toRemove)
	{
		if(start.visited)
			return 0;
		start.visited = true;
		int result = 0;
		start.sum = cost;
		if(start.sum > start.value)
			toRemove = true;
		ListIterator <Leaf> iter = start.to.listIterator();
		for(int i=0; iter.hasNext(); i++){
			Leaf next = iter.next();
			int tmp = removeIt(next, cost + start.costs.get(next), iter, toRemove);
			result += tmp;
		}
		if(toRemove || (start.to.isEmpty() && start.sum>start.value))
		{
			if(iter != null)
				iterAbove.remove();
			return result +1;
		}
		return result;
	}
}

class Leaf {
	boolean visited = false;
	int sum = -1;
	int value;
	LinkedList <Leaf> to =  new LinkedList <>();
	HashMap <Leaf, Integer> costs = new HashMap <> ();
	Leaf(int a )
	{
		this.value = a;
	}

}


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

public class AlyonaTree {

	static Leaf [] leaves ;

	public static void main(String[]args) throws Exception{
		BufferedReader buffy = new BufferedReader (new InputStreamReader (System.in));
		//Scanner scan = new Scanner (System.in);
		int numbLeaves = Integer.parseInt(buffy.readLine());
		leaves = new Leaf [numbLeaves];
		String [] str = buffy.readLine().split(" ");
		for(int i=0; i<numbLeaves; i++)
		{
			leaves[i] = new Leaf(Integer.parseInt(str[i]), i);
		}
		for(int i=0; i<numbLeaves-1; i++)
		{
			str = buffy.readLine().split(" ");
			int to = Integer.parseInt(str[0])-1;
			int cost = Integer.parseInt(str[1]); //scan.nextInt();
			leaves[i+1].to.add(leaves[to]);
			leaves[i+1].costs.put(leaves[to], cost);
			leaves[to].to.add(leaves[i+1]);
			leaves[to].costs.put(leaves[i+1], cost);
		}

		int result = removeIt(0, 0, null, false);
		System.out.println(result);

	}

	static int removeIt (int start, int cost, ListIterator <Leaf> iterAbove, boolean toRemove)
	{
		if(leaves[start].visited)
			return 0;
		leaves[start].visited = true;
		int result = 0;
		leaves[start].sum = cost;
		if(leaves[start].sum > leaves[start].value)
			toRemove = true;
		ListIterator <Leaf> iter = leaves[start].to.listIterator();
		for(int i=0; iter.hasNext(); i++){
			Leaf next = iter.next();
			int tmp = removeIt(next.place, Math.max(cost+leaves[start].costs.get(next), leaves[start].costs.get(next)), iter, toRemove);
			result += tmp;
		}
		if(toRemove || (leaves[start].to.isEmpty() && leaves[start].sum>leaves[start].value))
		{
			if(iterAbove != null)
				iterAbove.remove();
			return result +1;
		}
		return result;
	}
}

class Leaf {
	int place;
	boolean visited = false;
	int sum = -1;
	int value;
	LinkedList <Leaf> to =  new LinkedList <>();
	HashMap <Leaf, Integer> costs = new HashMap <> ();
	Leaf(int a , int place)
	{
		this.value = a;
		this.place = place;
	}
}


import java.util.*;

public class AlyonaTree {

	static Leaf [] leaves ;

	public static void main(String[]args){
		Scanner scan = new Scanner (System.in);
		int numbLeaves = scan.nextInt();
		leaves = new Leaf [numbLeaves];
		for(int i=0; i<numbLeaves; i++)
		{
			leaves[i] = new Leaf(scan.nextInt());
		}
		for(int i=0; i<numbLeaves-1; i++)
		{
			int to = scan.nextInt()-1;
			int cost = scan.nextInt();
			leaves[i+1].to.add(leaves[to]);
			leaves[i+1].costs.put(leaves[to], cost);
			leaves[to].to.add(leaves[i+1]);
			leaves[to].costs.put(leaves[i+1], cost);
		}

		int result = removeIt(leaves[0], 0, null, false);
		System.out.println(result);

	}

	static int removeIt (Leaf start, int cost, ListIterator <Leaf> iterAbove, boolean toRemove)
	{
		if(start.visited)
			return 0;
		start.visited = true;
		int result = 0;
		start.sum = cost;
		if(start.sum > start.value)
			toRemove = true;
		ListIterator <Leaf> iter = start.to.listIterator();
		for(int i=0; iter.hasNext(); i++){
			Leaf next = iter.next();
			int tmp = removeIt(next, Math.max(cost+start.costs.get(next), start.costs.get(next)), iter, toRemove);
			result += tmp;
		}
		if(toRemove || (start.to.isEmpty() && start.sum>start.value))
		{
			if(iterAbove != null)
				iterAbove.remove();
			return result +1;
		}
		return result;
	}
}

class Leaf {
	boolean visited = false;
	int sum = -1;
	int value;
	LinkedList <Leaf> to =  new LinkedList <>();
	HashMap <Leaf, Integer> costs = new HashMap <> ();
	Leaf(int a )
	{
		this.value = a;
	}
}


import java.util.*;

public class AlyonaTree {

	static Leaf [] leaves ;

	public static void main(String[]args){
		Scanner scan = new Scanner (System.in);
		int numbLeaves = scan.nextInt();
		leaves = new Leaf [numbLeaves];
		for(int i=0; i<numbLeaves; i++)
		{
			leaves[i] = new Leaf(scan.nextInt(), i);
		}
		for(int i=0; i<numbLeaves-1; i++)
		{
			int to = scan.nextInt()-1;
			int cost = scan.nextInt();
			leaves[i+1].to.add(leaves[to]);
			leaves[i+1].costs.put(leaves[to], cost);
			leaves[to].to.add(leaves[i+1]);
			leaves[to].costs.put(leaves[i+1], cost);
		}

		int result = removeIt(0, 0, null, false);
		System.out.println(result);

	}

	static int removeIt (int start, int cost, ListIterator <Leaf> iterAbove, boolean toRemove)
	{
		if(leaves[start].visited)
			return 0;
		leaves[start].visited = true;
		int result = 0;
		leaves[start].sum = cost;
		if(leaves[start].sum > leaves[start].value)
			toRemove = true;
		ListIterator <Leaf> iter = leaves[start].to.listIterator();
		for(int i=0; iter.hasNext(); i++){
			Leaf next = iter.next();
			int tmp = removeIt(next.place, Math.max(cost+leaves[start].costs.get(next), leaves[start].costs.get(next)), iter, toRemove);
			result += tmp;
		}
		if(toRemove || (leaves[start].to.isEmpty() && leaves[start].sum>leaves[start].value))
		{
			if(iterAbove != null)
				iterAbove.remove();
			return result +1;
		}
		return result;
	}
}

class Leaf {
	int place;
	boolean visited = false;
	int sum = -1;
	int value;
	LinkedList <Leaf> to =  new LinkedList <>();
	HashMap <Leaf, Integer> costs = new HashMap <> ();
	Leaf(int a , int place)
	{
		this.value = a;
		this.place = place;
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer buffer;

    public static void solve() {
    	int n = ni();
    	int[]a = ni(n);
    	List<Integer>[] adj = new List[n];
    	List<Integer>[] dist = new List[n];
    	for (int i=0;i<n;i++) {
    		adj[i] = new ArrayList<Integer>();
    		dist[i] = new ArrayList<Integer>();
    	}

    	for (int i=0;i<n-1;i++) {
    		int x = ni(), y = ni();
    		adj[i+1].add(x-1);
    		adj[x-1].add(i+1);
    		dist[i+1].add(y);
    		dist[x-1].add(y);
    	}

    	int[]maxEndingHere = new int[n];
    	Arrays.fill(maxEndingHere, Integer.MIN_VALUE);
    	maxEndingHere[0] = 0;

    	boolean[]remove = new boolean[n];
    	boolean[]used = new boolean[n];

    	List<Integer>dfs = new ArrayList<Integer>();
    	dfs.add(0);
    	used[0] = true;
    	int pos = 0;
    	while (pos<dfs.size()) {
    		int ver = dfs.get(pos);
    		for (int i=0;i<adj[ver].size();i++) {
    			int nei = adj[ver].get(i);
    			if (!used[nei]) {
    				dfs.add(nei);
    				used[nei] = true;
    				if (remove[ver]) remove[nei] = true;
    				maxEndingHere[nei] = Math.max(maxEndingHere[ver]+dist[ver].get(i), dist[ver].get(i));
    				if (maxEndingHere[nei]>a[nei]) remove[nei] = true;
    			}
    		}

    		pos++;
    	}

    	int total = 0;
    	for (int i=0;i<n;i++) {
    		if (remove[i]) total++;
    	}

    	out.println(total);

    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    static String next() {
        while (buffer == null || !buffer.hasMoreElements()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
            }
        }
        return buffer.nextToken();
    }

    static int ni() {
        return Integer.parseInt(next());
    }

    static long nl() {
        return Long.parseLong(next());
    }

    static double nd() {
        return Double.parseDouble(next());
    }

    static String ns() {
        return next();
    }

    static int[] ni(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++)
            res[i] = Integer.parseInt(next());
        return res;
    }

    static long[] nl(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++)
            res[i] = Long.parseLong(next());
        return res;
    }

    static double[] nd(int n) {
        double[] res = new double[n];
        for (int i = 0; i < n; i++)
            res[i] = Double.parseDouble(next());
        return res;
    }

    static String[] ns(int n) {
        String[] res = new String[n];
        for (int i = 0; i < n; i++)
            res[i] = next();
        return res;
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer buffer;

    public static void solve() {
    	int n = ni();
    	int[]a = ni(n);
    	List<Integer>[] adj = new List[n];
    	for (int i=0;i<n;i++) adj[i] = new ArrayList<Integer>();

    	int[][]dist = new int[n][n];
    	for (int i=0;i<n-1;i++) {
    		int x = ni(), y = ni();
    		adj[i+1].add(x-1);
    		adj[x-1].add(i+1);
    		dist[i+1][x-1] = dist[x-1][i+1] = y;
    	}

    	int[]maxEndingHere = new int[n];
    	Arrays.fill(maxEndingHere, Integer.MIN_VALUE);
    	maxEndingHere[0] = 0;

    	boolean[]remove = new boolean[n];
    	boolean[]used = new boolean[n];

    	List<Integer>dfs = new ArrayList<Integer>();
    	dfs.add(0);
    	used[0] = true;
    	int pos = 0;
    	while (pos<dfs.size()) {
    		int ver = dfs.get(pos);
    		for (int i=0;i<adj[ver].size();i++) {
    			int nei = adj[ver].get(i);
    			if (!used[nei]) {
    				dfs.add(nei);
    				used[nei] = true;
    				if (remove[ver]) remove[nei] = true;
    				maxEndingHere[nei] = Math.max(maxEndingHere[ver]+dist[ver][nei], dist[ver][nei]);
    				if (maxEndingHere[nei]>a[nei]) remove[nei] = true;
    			}
    		}

    		pos++;
    	}

    	int total = 0;
    	for (int i=0;i<n;i++) {
    		if (remove[i]) total++;
    	}

    	out.println(total);

    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    static String next() {
        while (buffer == null || !buffer.hasMoreElements()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
            }
        }
        return buffer.nextToken();
    }

    static int ni() {
        return Integer.parseInt(next());
    }

    static long nl() {
        return Long.parseLong(next());
    }

    static double nd() {
        return Double.parseDouble(next());
    }

    static String ns() {
        return next();
    }

    static int[] ni(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++)
            res[i] = Integer.parseInt(next());
        return res;
    }

    static long[] nl(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++)
            res[i] = Long.parseLong(next());
        return res;
    }

    static double[] nd(int n) {
        double[] res = new double[n];
        for (int i = 0; i < n; i++)
            res[i] = Double.parseDouble(next());
        return res;
    }

    static String[] ns(int n) {
        String[] res = new String[n];
        for (int i = 0; i < n; i++)
            res[i] = next();
        return res;
    }

}