#include <bits/stdc++.h>
using namespace std;
const int maxn = 200020, maxl = 28;
int n, a[maxn], par[maxl][maxn], close[maxn], d[maxn], ans[maxn];
long long dist[maxl][maxn];
vector<int> adj[maxn];
int dfs(int x) {
  for (int y : adj[x]) {
    ans[x] += dfs(y);
  }
  return ans[x] + 1 - close[x];
}
void dfsd(int x) {
  for (int y : adj[x]) {
    d[y] = d[x] + 1;
    dfsd(y);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int p, w;
  for (int i = 2; i <= n; i++) {
    scanf("%d %d", &p, &w);
    par[0][i] = p;
    adj[p].push_back(i);
    dist[0][i] = w;
  }
  for (int k = 1; k < maxl; k++) {
    for (int i = 1; i <= n; i++) {
      par[k][i] = par[k - 1][par[k - 1][i]];
      dist[k][i] = dist[k - 1][i] + dist[k - 1][par[k - 1][i]];
    }
  }
  dfsd(1);
  for (int i = 1; i <= n; i++) {
    int lo = 0, hi = d[i], mid;
    while (lo < hi) {
      mid = (lo + hi + 1) / 2;
      long long sum = 0;
      int j = i;
      for (int k = 0; k < maxl; k++) {
        if (mid & (1 << k)) {
          sum += dist[k][j];
          j = par[k][j];
        }
      }
      if (sum > a[i]) {
        hi = mid - 1;
      } else {
        lo = mid;
      }
    }
    int j = i;
    for (int k = 0; k < maxl; k++) {
      if (lo & (1 << k)) {
        j = par[k][j];
      }
    }
    close[j]++;
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
