#include <bits/stdc++.h>
using namespace std;
long long n, l;
vector<long long> a;
vector<vector<pair<long long, long long> > > adj;
long long timer;
vector<long long> tin, tout;
vector<vector<long long> > up;
vector<long long> summ;
void dfs(long long x, long long p) {
  tin[x] = ++timer;
  up[x][0] = p;
  for (long long i = 1; i <= l; i++) {
    up[x][i] = up[up[x][i - 1]][i - 1];
  }
  for (auto it : adj[x]) {
    if (it.first != p) {
      dfs(it.first, x);
    }
  }
  tout[x] = ++timer;
}
long long wlk(long long u, long long k) {
  for (long long i = l; i >= 0; --i) {
    if ((k) & (1 << i)) u = up[u][i];
  }
  return u;
}
void preprocess() {
  timer = 0;
  tin.resize(n);
  tout.resize(n);
  l = (long long)((ceil)(log2(n)));
  up.resize(n, vector<long long>(l + 1));
  dfs(0, 0);
}
vector<long long> dist;
vector<long long> ht;
void dis(long long idx, long long p, long long cost, long long h) {
  dist[idx] = cost;
  ht[idx] = h;
  for (auto it : adj[idx]) {
    if (it.first != p) {
      dis(it.first, idx, cost + it.second, h + 1);
    }
  }
}
long long newdfs(long long idx, long long parent) {
  long long cost = summ[idx];
  for (auto it : adj[idx]) {
    if (it.first != parent) {
      cost += newdfs(it.first, idx);
    }
  }
  summ[idx] = cost;
  return summ[idx];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  a.resize(n);
  adj.resize(n);
  ht.resize(n, 0);
  summ.resize(n, 0);
  dist.resize(n, 0);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 1; i <= n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    --x;
    adj[i].push_back(make_pair(x, y));
    adj[x].push_back(make_pair(i, y));
  }
  preprocess();
  dis(0, 0, 0, 0);
  for (long long i = 1; i < n; i++) {
    long long pp = a[i];
    long long low = 0, high = ht[i], mid;
    long long ans = 0;
    while (low <= high) {
      mid = (low + high) / 2;
      long long xx = wlk(i, mid);
      long long tot = dist[i] - dist[xx];
      if (tot <= pp) {
        ans = xx;
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    long long fr = wlk(i, 1);
    long long ap = wlk(ans, 1);
    if (fr != i) {
      summ[fr]++;
      if (ap != ans) {
        summ[ap]--;
      }
    }
  }
  newdfs(0, 0);
  for (long long i = 0; i < n; i++) cout << summ[i] << " ";
  return 0;
}
