#include <bits/stdc++.h>
using namespace std;
long long n;
struct node {
  long long u, v;
  long long next;
  long long val;
} G[200010];
long long tot = 0;
long long head[200010];
void add(long long u, long long v, long long val) {
  tot++;
  G[tot].u = u;
  G[tot].v = v;
  G[tot].val = val;
  G[tot].next = head[u];
  head[u] = tot;
}
long long ctrl[200010];
long long ans[200010];
long long stk[200010], si = 0;
long long f[200010];
void dfs(long long u) {
  si++;
  stk[si] = u;
  long long left = 1, right = si;
  while (left < right) {
    long long mid = (left + right) / 2;
    if (f[stk[mid]] >= f[u] - ctrl[u])
      right = mid;
    else
      left = mid + 1;
  }
  ans[stk[si - 1]]++;
  ans[stk[left - 1]]--;
  for (long long i = head[u]; i; i = G[i].next) {
    long long v = G[i].v;
    f[v] = G[i].val + f[u];
    dfs(v);
    ans[u] += ans[v];
  }
  si--;
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &ctrl[i]);
  }
  for (long long i = 1; i < n; i++) {
    long long u, val;
    scanf("%lld%lld", &u, &val);
    add(u, i + 1, val);
  }
  dfs(1);
  for (long long i = 1; i <= n; i++) {
    printf("%lld ", ans[i]);
  }
  return 0;
}
