#include <bits/stdc++.h>
using namespace std;
long long n, a[200200], fa[200200][20], d[200200][20], dep[200200], ans[200200];
struct R {
  long long to, val, nex;
} r[520233];
long long hea[520233], cnt;
void A(long long u, long long v, long long w) {
  r[++cnt] = (R){v, w, hea[u]};
  hea[u] = cnt;
}
void dfs(int x, int par) {
  dep[x] = dep[par] + 1;
  for (int i = 1; i < 20; i++) {
    if (dep[x] > (1 << i)) {
      fa[x][i] = fa[fa[x][i - 1]][i - 1];
      d[x][i] = d[x][i - 1] + d[fa[x][i - 1]][i - 1];
    } else {
      break;
    }
  }
  int y;
  for (int i = hea[x]; i > 0; i = r[i].nex) {
    y = r[i].to;
    if (y == par) continue;
    fa[y][0] = x;
    d[y][0] = r[i].val;
    dfs(y, x);
  }
}
int doit(int x) {
  long long t = a[x];
  for (int i = 19; i >= 0; i--) {
    if (dep[x] > (1 << i) && t >= d[x][i]) {
      t -= d[x][i];
      x = fa[x][i];
    }
  }
  return x;
}
void getans(int x, int par) {
  int y;
  for (int i = hea[x]; i > 0; i = r[i].nex) {
    y = r[i].to;
    if (y == par) continue;
    getans(y, x);
    ans[x] += ans[y];
  }
}
int main() {
  scanf("%I64d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
  }
  int p, w;
  memset(hea, 0, sizeof(hea));
  cnt = 1;
  for (int i = 2; i <= n; i++) {
    scanf("%d%d", &p, &w);
    A(p, i, w);
    A(i, p, w);
  }
  memset(fa, 0, sizeof(fa));
  dep[0] = 0;
  dfs(1, 0);
  memset(ans, 0, sizeof(ans));
  for (int i = 2; i <= n; i++) {
    p = doit(i);
    ans[fa[p][0]]--;
    ans[fa[i][0]]++;
  }
  getans(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%I64d ", ans[i]);
  }
}
