#include <bits/stdc++.h>
using std::make_pair;
using std::pair;
const int N = 2e5 + 1e3;
struct edge {
  int next, to, v;
} e[N << 1];
int n, m;
int last[N], cnt;
long long d[N];
std::multiset<long long> s;
int ans[N], a[N];
long long val[N];
int ls[N], rt, size[N], rs[N], sz, rky[N];
void add(int a, int b, int c) {
  cnt++;
  e[cnt].next = last[a], last[a] = cnt;
  e[cnt].to = b;
  e[cnt].v = c;
}
int new_node(long long v) {
  int x = ++sz;
  rky[x] = rand();
  val[x] = v;
  ls[x] = rs[x] = 0;
  size[x] = 1;
  return sz;
}
void pushup(int x) { size[x] = 1 + size[ls[x]] + size[rs[x]]; }
int merge(int x, int y) {
  if (!x || !y) return x | y;
  int r;
  if (rky[x] < rky[y]) {
    rs[r = x] = merge(rs[x], y);
  } else
    ls[r = y] = merge(x, ls[y]);
  pushup(r);
  return r;
}
void split(int now, long long k, int &x, int &y) {
  if (!now) {
    return (void)(x = y = 0);
  }
  if (val[now] <= k) {
    x = now;
    split(rs[now], k, rs[x], y);
  } else {
    y = now;
    split(ls[now], k, x, ls[y]);
  }
  pushup(now);
}
void insert(long long v) {
  int x, y;
  split(rt, v, x, y);
  x = merge(x, new_node(v));
  rt = merge(x, y);
}
int find(long long v) {
  int x, y;
  split(rt, v, x, y);
  int ans = size[x];
  rt = merge(x, y);
  return ans;
}
void dfs1(int x, int f) {
  insert(d[x] - a[x]);
  ans[x] -= find(d[x]);
  for (int i = last[x]; i; i = e[i].next) {
    if (e[i].to == f) continue;
    d[e[i].to] = d[x] + e[i].v;
    dfs1(e[i].to, x);
  }
  ans[x] += find(d[x]);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 2; i <= n; ++i) {
      int x, y;
      scanf("%d %d", &x, &y);
      add(x, i, y);
    }
    dfs1(1, 0);
    for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  }
}
