#include <bits/stdc++.h>
using namespace std;
const int maxn = 300500;
long long toit[maxn * 2], Next[maxn * 2], link[maxn], len[maxn * 2], a[maxn], n,
    m, cnt = 0, dep[maxn], fa[maxn][40], mp[maxn];
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void add(int u, int v, int w) {
  toit[++cnt] = v;
  Next[cnt] = link[u];
  link[u] = cnt;
  len[cnt] = w;
  toit[++cnt] = u;
  Next[cnt] = link[v];
  link[v] = cnt;
  len[cnt] = w;
}
inline void dfs(int x, int f) {
  for (int w = link[x]; w; w = Next[w]) {
    int v = toit[w];
    if (v == f) continue;
    dep[v] = dep[x] + len[w];
    fa[v][0] = x;
    dfs(v, x);
  }
}
inline void getans(int x, int f) {
  for (int w = link[x]; w; w = Next[w]) {
    int v = toit[w];
    if (v == f) continue;
    getans(v, x);
    mp[x] += mp[v];
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 2; i <= n; ++i) {
    int v = read(), w = read();
    add(i, v, w);
  }
  dep[1] = 0;
  dfs(1, 0);
  for (int j = 1; j <= 20; ++j)
    for (int i = 1; i <= n; ++i) fa[i][j] = fa[fa[i][j - 1]][j - 1];
  for (int i = 2; i <= n; ++i) {
    int j = 20;
    while (fa[i][j] == 0 && j > 0) --j;
    while (1) {
      int x = fa[i][j];
      if (dep[i] - dep[x] <= a[i]) break;
      if (dep[i] - dep[x] > a[i]) --j;
      if (j < 0) break;
    }
    if (j < 0) continue;
    ++mp[fa[i][0]];
    int x = fa[i][j];
    for (int t = 20; t >= 0; --t) {
      while (dep[i] - dep[fa[x][t]] <= a[i] && fa[x][t] != 0) x = fa[x][t];
    }
    if (x == 1) continue;
    --mp[fa[x][0]];
  }
  getans(1, 0);
  for (int i = 1; i <= n; ++i) printf("%lld ", mp[i]);
  return 0;
}
