#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 233;
struct zs {
  int too, dis, pre;
} e[maxn];
int tot, last[maxn];
long long dis[maxn];
int fa[maxn], dep[maxn], mp[maxn], a[maxn], add[maxn], sum[maxn];
int i, j, k, n, m;
int ra;
char rx;
inline int read() {
  rx = getchar(), ra = 0;
  while (rx < '0') rx = getchar();
  while (rx > 47) ra = ra * 10 + rx - 48, rx = getchar();
  return ra;
}
inline void insert(int a, int b, int c) {
  e[++tot].too = b, e[tot].dis = c, e[tot].pre = last[a], last[a] = tot;
}
void dfs(int x, int f) {
  int i, to, l, r, mid;
  dep[x] = dep[f] + 1, mp[dep[x]] = x;
  l = 1, r = dep[x];
  while (l < r)
    if (dis[x] - dis[mp[mid = (l + r) >> 1]] <= a[x])
      r = mid;
    else
      l = mid + 1;
  add[f]++, add[fa[mp[l]]]--;
  for (i = last[x]; i; i = e[i].pre)
    if ((to = e[i].too) != f)
      dis[to] = dis[x] + e[i].dis, fa[to] = x, dfs(to, x), sum[x] += sum[to];
  sum[x] += add[x];
}
int main() {
  n = read();
  for (i = 1; i <= n; i++) a[i] = read();
  for (i = 2; i <= n; i++) j = read(), insert(j, i, read());
  dfs(1, 0);
  for (i = 1; i <= n; i++) printf("%d ", sum[i]);
}
