#include <bits/stdc++.h>
using namespace std;
int n, p, par[200100];
int ans[200100];
long long a[200100];
long long dp[200100];
vector<pair<int, long long> > v[200100];
void dfs(int me, long long dist, int j) {
  par[j] = me;
  dp[j] = dist;
  int idx = lower_bound(dp, dp + j + 1, dist - a[me]) - dp - 1;
  ans[par[idx]]--;
  ans[me] = 1;
  for (int i = 0; i < v[me].size(); i++) {
    dfs(v[me][i].first, dist + v[me][i].second, j + 1);
    ans[me] += ans[v[me][i].first];
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int x;
  for (int i = 2; i <= n; i++) {
    cin >> p >> x;
    v[p].push_back({i, x});
  }
  dp[0] = -(LLONG_MAX);
  dfs(1, 0, 1);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] - 1 << " ";
    cout << endl;
  }
  return 0;
}
