#include <bits/stdc++.h>
using namespace std;
const int maxn = 400500;
struct edge {
  int obj, pre;
  long long c;
} e[maxn];
struct data {
  int op, id;
  long long x;
  bool friend operator<(data a, data b) {
    return a.x < b.x || (a.x == b.x && a.op < b.op);
  }
} q[maxn];
int t[maxn], head[maxn], ans[maxn], l[maxn], r[maxn];
long long d[maxn], a[maxn];
int tot, n, idx;
void insert(int x, int y, long long c) {
  e[++tot].obj = y;
  e[tot].pre = head[x];
  e[tot].c = c;
  head[x] = tot;
}
void dfs(int u) {
  l[u] = ++idx;
  for (int j = head[u]; j; j = e[j].pre) {
    int v = e[j].obj;
    d[v] = d[u] + e[j].c;
    dfs(v);
  }
  r[u] = idx;
}
void add(int x, int y) {
  while (x <= n) {
    t[x] += y;
    x += ((x) & (-x));
  }
}
int ask(int x) {
  int sum = 0;
  while (x) {
    sum += t[x];
    x -= ((x) & (-x));
  }
  return sum;
}
void solve() {
  scanf("%d", &n);
  tot = idx = 0;
  for (int i = 1; i <= n; i++) head[i] = l[i] = r[i] = ans[i] = t[i] = d[i] = 0;
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 2; i <= n; i++) {
    int x;
    long long c;
    scanf("%d%lld", &x, &c);
    insert(x, i, c);
  }
  dfs(1);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    q[++cnt] = (data){0, i, d[i] - a[i]};
    q[++cnt] = (data){1, i, d[i]};
  }
  sort(q + 1, q + 1 + cnt);
  for (int i = 1; i <= cnt; i++) {
    if (q[i].op == 0)
      add(l[q[i].id], 1);
    else
      ans[q[i].id] = ask(r[q[i].id]) - ask(l[q[i].id] - 1);
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i] - 1);
}
int main() {
  solve();
  return 0;
}
