#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(long long u, long long par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vector<pair<long long, long long> > g[N];
int a[N];
vector<long long> v;
long long ans = 0;
vector<long long> dist;
void solve() {
  long long i, j, n, k, data, m, f = 1;
  cin >> n;
  dist.resize(n);
  for (i = 0; i < n; i++) {
    cin >> data;
    v.push_back(data);
    dist[i] = 0;
  }
  if (n == 1) {
    cout << "0\n";
    return;
  }
  ipgraph(n, n - 1);
  dfs(0, -1);
  cout << n - ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
void ipgraph(int n, int m) {
  int i = 0, u, v;
  while (m--) {
    cin >> u >> v;
    u--;
    i++;
    g[i].push_back(make_pair(u, v));
    g[u].push_back(make_pair(i, v));
  }
}
void dfs(long long u, long long par) {
  if (dist[u] > v[u]) {
    return;
  }
  if (dist[u] <= v[u]) {
    ans++;
  }
  for (auto x : g[u]) {
    if (x.first == par) continue;
    dist[x.first] = max(dist[u], 0ll) + x.second;
    dfs(x.first, u);
  }
}
