#include <bits/stdc++.h>
const int MAXN = 1000000;
struct edge {
  int t, c;
  edge *p;
} e[MAXN], *v[MAXN];
int n, es = -1;
int a[MAXN], baba[MAXN], h, ans[MAXN];
long long dep[MAXN];
inline void addedge(int i, int j, int k) {
  e[++es].t = j;
  e[es].c = k;
  e[es].p = v[i];
  v[i] = e + es;
}
int bisearch(long long key) {
  int l = 0, r = h;
  while (r > l) {
    int mid = l + r >> 1;
    if (dep[baba[mid]] >= key)
      r = mid;
    else
      l = mid + 1;
  }
  return l - 1;
}
int dfs(int u, long long depth) {
  dep[u] = depth;
  if (h) {
    ans[baba[h - 1]]++;
    ans[baba[bisearch(depth - a[u])]]--;
  }
  baba[h++] = u;
  for (edge *x = v[u]; x; x = x->p) ans[u] += dfs(x->t, depth + x->c);
  --h;
  return ans[u];
}
int main() {
  memset(ans, 0, sizeof(ans));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 2; i <= n; i++) {
    int j, k;
    scanf("%d%d", &j, &k);
    addedge(j, i, k);
  }
  h = 0;
  dfs(1, 0LL);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
