#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s * f;
}
struct edge {
  int v, w, nxt;
} e[2 * 200005];
struct BIT {
  int c[200005], sz;
  inline void init(int x) { sz = x; }
  inline void add(int p, int v) {
    for (; p <= sz; p += ((p) & (-(p)))) c[p] += v;
  }
  inline int sum(int p) {
    int ret = 0;
    for (; p > 0; p -= ((p) & (-(p)))) ret += c[p];
    return ret;
  }
} bit;
long long dis[200005], unq[200005];
int n, s[200005], prv[200005], w[200005], tot, cnt, ans[200005];
inline void dfs1(int u, int ft) {
  for (int i = prv[u]; i; i = e[i].nxt)
    if (e[i].v != ft) dis[e[i].v] = dis[u] + e[i].w, dfs1(e[i].v, u);
}
inline int rnk(long long x) {
  int ret = lower_bound(unq + 1, unq + 1 + cnt, x) - unq;
  if (unq[ret] == x)
    return ret;
  else
    return ret - 1;
}
inline void dfs2(int u, int ft) {
  int pos = rnk(dis[u]), curans = bit.sum(pos);
  for (int i = prv[u]; i; i = e[i].nxt)
    if (e[i].v != ft) dfs2(e[i].v, u);
  ans[u] = bit.sum(pos) - curans;
  bit.add(w[u], 1);
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) s[i] = read();
  for (int i = 2; i <= n; ++i) {
    int u = i, v = read(), w = read();
    e[++tot] = (edge){v, w, prv[u]}, prv[u] = tot;
    e[++tot] = (edge){u, w, prv[v]}, prv[v] = tot;
  }
  dfs1(1, 0);
  for (int i = 1; i <= n; ++i) unq[i] = dis[i];
  sort(unq + 1, unq + 1 + n), cnt = unique(unq + 1, unq + 1 + n) - unq - 1;
  for (int i = 1; i <= n; ++i)
    w[i] = lower_bound(unq + 1, unq + 1 + cnt, dis[i] - s[i]) - unq;
  bit.init(cnt + 2);
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
}
