#include <bits/stdc++.h>
using namespace std;
const int N = int(3e5), mod = int(1e9) + 7;
int n, a[N], tin[N], tout[N], t;
vector<pair<int, int> > g[N];
long long d[N];
pair<long long, int> p[N], q[N];
int tt[2 * N];
void dfs(int v, long long ds) {
  d[v] = ds;
  tin[v] = ++t;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    dfs(to, ds + g[v][i].second);
  }
  tout[v] = t;
}
void upd(int v) {
  v += t - 1;
  tt[v]++;
  while (v > 1) {
    v >>= 1;
    tt[v] = tt[v + v] + tt[v + v + 1];
  }
}
int get(int l, int r) {
  l += t - 1;
  r += t - 1;
  int res = 0;
  while (l <= r) {
    if (l & 1) res += tt[l];
    if (!(r & 1)) res += tt[r];
    l = (l + 1) / 2;
    r = (r - 1) / 2;
  }
  return res;
}
int ans[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    int p, w;
    scanf("%d%d", &p, &w);
    g[p].push_back(make_pair(i, w));
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    p[i] = make_pair(d[i], i);
    q[i] = make_pair(d[i] - a[i], i);
  }
  sort(p + 1, p + n + 1);
  sort(q + 1, q + n + 1);
  int j = 1;
  for (int i = 1; i <= n; i++) {
    int v = p[i].second;
    while (j <= n && q[j].first <= d[v]) {
      upd(tin[q[j].second]);
      j++;
    }
    ans[v] = get(tin[v], tout[v]);
  }
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i] - 1);
  }
  return 0;
}
