#include <bits/stdc++.h>
using namespace std;
vector<long long> g[200005], cost[200005];
long long n, m;
long long parr[200005];
bool visit[200005];
long long ara[200005];
long long child[200005], special[200005];
void dfs(long long u) {
  visit[u] = 1;
  long long len = g[u].size(), i, mx = 0, idx = -1;
  child[u] = 0;
  for (i = 0; i < len; i++) {
    long long v = g[u][i];
    if (visit[v] == 0) {
      parr[v] = u;
      dfs(v);
      if (child[v] > mx) {
        mx = child[v];
        idx = v;
      }
      child[u] += child[v];
    }
  }
  child[u]++;
  special[u] = idx;
}
long long head[200005], tail[200005], dis[200005], path[200005],
    chaindx[200005], cn, sand;
void HLD(long long u) {
  sand++;
  if (head[cn] == -1) head[cn] = sand;
  tail[cn] = sand;
  dis[u] = sand;
  path[sand] = u;
  chaindx[sand] = cn;
  if (special[u] != -1) HLD(special[u]);
  long long len = g[u].size(), i;
  for (i = 0; i < len; i++) {
    long long v = g[u][i];
    if (v == parr[u] || v == special[u]) continue;
    cn++;
    HLD(v);
  }
}
long long L[200005], par[200005][20], col;
void go(long long u, long long dept) {
  L[u] = dept;
  long long len = g[u].size(), i;
  for (i = 0; i < len; i++) {
    long long v = g[u][i];
    if (par[u][0] != v) {
      par[v][0] = u;
      go(v, dept + 1);
    }
  }
}
void init() {
  col = (long long)(log10((double)(n - 1)) / log10(2.0)) + 1;
  memset(par, -1, sizeof(par));
  go(1, 0);
  long long i, j;
  for (j = 1; j <= col; j++) {
    for (i = 1; i <= n; i++) {
      if (par[i][j - 1] != -1) {
        par[i][j] = par[par[i][j - 1]][j - 1];
      }
    }
  }
}
long long query(long long a, long long b) {
  long long i;
  if (L[a] < L[b]) swap(a, b);
  for (i = col; i >= 0; i--) {
    if (L[a] - (1 << i) >= L[b]) {
      a = par[a][i];
    }
  }
  if (a == b) return a;
  for (i = col; i >= 0; i--) {
    if (par[a][i] != -1 && par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}
long long Dist[200005];
void D(long long u, long long d) {
  visit[u] = 1;
  Dist[u] = d;
  long long len = g[u].size(), i;
  for (i = 0; i < len; i++) {
    long long v = g[u][i];
    if (visit[v] == 0) {
      D(v, d + cost[u][i]);
    }
  }
}
void prework() {
  cn = 1;
  memset(head, -1, sizeof(head));
  dfs(1);
  HLD(1);
  init();
  memset(visit, 0, sizeof(visit));
  D(1, 0);
}
inline long long calc(long long u, long long v) {
  return llabs(Dist[v] - Dist[u]);
}
long long tree[4 * 200005];
void U(long long ind, long long b, long long e, long long i, long long j) {
  if (i > j) return;
  if (b == i && e == j) {
    tree[ind]++;
    return;
  }
  long long mid = (b + e) / 2, l = 2 * ind, r = l + 1;
  U(l, b, mid, i, min(j, mid));
  U(r, mid + 1, e, max(mid + 1, i), j);
}
long long lol[200005];
void Push(long long ind, long long b, long long e, long long car) {
  if (b == e) {
    lol[b] = car + tree[ind];
    return;
  }
  long long mid = (b + e) / 2, l = 2 * ind, r = l + 1;
  Push(l, b, mid, car + tree[ind]);
  Push(r, mid + 1, e, car + tree[ind]);
}
void F(long long x, long long y) {
  long long cur = y;
  long long mn = dis[x];
  mn = chaindx[mn];
  while (1) {
    long long d1 = dis[cur];
    long long my = chaindx[d1];
    if (my == mn) {
      long long d2 = dis[x];
      U(1, 1, n, d2, d1);
      break;
    } else {
      long long d2 = head[my];
      U(1, 1, n, d2, d1);
      long long kase = path[d2];
      cur = parr[kase];
    }
  }
}
void Do(long long u) {
  long long cur = u, ans = u, d;
  for (long long i = col; i >= 0; i--) {
    long long p = par[cur][i];
    if (p == -1)
      d = LLONG_MAX;
    else {
      d = calc(u, p);
      if (d <= ara[u]) {
        ans = p;
        cur = p;
      }
    }
  }
  F(ans, u);
}
long long pr[200005];
int main() {
  long long i, x, w;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &ara[i]);
  for (i = 2; i <= n; i++) {
    scanf("%lld", &x);
    scanf("%lld", &w);
    g[x].push_back(i);
    g[i].push_back(x);
    cost[x].push_back(w);
    cost[i].push_back(w);
  }
  prework();
  for (i = 1; i <= n; i++) Do(i);
  Push(1, 1, n, 0);
  for (i = 1; i <= n; i++) {
    long long u = path[i];
    pr[u] = lol[i];
  }
  for (i = 1; i <= n; i++) {
    if (i > 1) printf(" ");
    printf("%lld", pr[i] - 1);
  }
  printf("\n");
  return 0;
}
