#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 200000 + 100;
long long a[maxn], b[maxn][20], c[maxn][20], s[maxn];
vector<pair<int, long long> > G[maxn];
int ans[maxn], par[maxn], dep[maxn];
pair<int, long long> rec[maxn];
int n, cnt;
bool cmp(pair<int, long long> a, pair<int, long long> b) {
  return a.second > b.second;
}
void dfs_1(int u, int fa, long long sum) {
  int v;
  par[u] = fa;
  s[u] = sum;
  dep[u] = dep[fa] + 1;
  rec[cnt++] = pair<int, long long>(u, dep[u]);
  for (int i = 0; i < G[u].size(); ++i) {
    v = G[u][i].first;
    dfs_1(v, u, sum + G[u][i].second);
  }
}
void dfs(int u, int sum) {
  int v;
  ans[u] = sum;
  for (int i = 0; i < G[u].size(); ++i) {
    v = G[u][i].first;
    dfs(v, sum + ans[v]);
  }
}
int main() {
  int T, cas = 1, fa, w;
  memset(c, 0x3f, sizeof c);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%lld\n", &a[i]);
  for (int i = 2; i <= n; ++i) {
    scanf("%d%d", &fa, &w);
    G[fa].push_back(pair<int, long long>(i, w));
  }
  dfs_1(1, 0, 0);
  for (int i = 1; i <= n; ++i) b[i][0] = i, c[i][0] = 0;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j < 20; ++j) {
      if (b[par[b[i][j - 1]]][j - 1] == 0) break;
      b[i][j] = b[par[b[i][j - 1]]][j - 1];
      c[i][j] = s[b[i][0]] - s[b[i][j]];
    }
  }
  for (int i = 2; i <= n; ++i) {
    int j = 19, u = i;
    long long tmp = 0;
    while (j > 0) {
      if (a[i] - tmp - c[u][j] >= 0)
        tmp += c[u][j], u = b[u][j];
      else
        --j;
    }
    ans[par[u]]--;
    ans[par[i]]++;
  }
  sort(rec, rec + cnt, cmp);
  for (int i = 0; i < cnt; ++i) {
    int u = rec[i].first;
    ans[par[u]] += ans[u];
  }
  for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  return 0;
}
