#include <bits/stdc++.h>
using namespace std;
int n, par[200000][18], dist[200000], ans[200000];
long long a[200000], b[200000], pre[200000];
vector<int> g[200000];
void dfs(int x) {
  for (int i = 1; i < 18; i++) par[x][i] = par[par[x][i - 1]][i - 1];
  dist[x] = dist[par[x][0]] + 1;
  pre[x] = b[x];
  if (x != 0) pre[x] += pre[par[x][0]];
  for (int i = 0; i < g[x].size(); i++) dfs(g[x][i]);
}
void dfs2(int x) {
  for (int i = 0; i < g[x].size(); i++) {
    dfs2(g[x][i]);
    ans[x] += ans[g[x][i]];
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> par[i + 1][0] >> b[i + 1];
    par[i + 1][0]--;
    g[par[i + 1][0]].push_back(i + 1);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    ans[i]++;
    int cur = i;
    for (int j = 17; j >= 0; j--) {
      int x = par[cur][j];
      long long y = pre[i] - pre[x];
      if (y <= a[i]) cur = x;
    }
    if (cur != 0) ans[par[cur][0]]--;
  }
  dfs2(0);
  for (int i = 0; i < n; i++) {
    cout << ans[i] - 1 << " ";
  }
  cout << endl;
}
