#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int par[30][MAXN], cnt[MAXN], ans[MAXN], d[MAXN], ad[MAXN];
long long dis[30][MAXN];
vector<pair<int, long long> > a[MAXN];
void dfs_p(int v, int parent, long long w) {
  if (parent != -1) {
    dis[0][v] = w;
    par[0][v] = parent;
    for (int i = 1; i < 25; i++) par[i][v] = par[i - 1][par[i - 1][v]];
    for (int i = 1; i < 25; i++)
      dis[i][v] = dis[i - 1][v] + dis[i - 1][par[i - 1][v]];
  }
  for (auto u : a[v]) {
    if (u.first == parent) continue;
    d[u.first] = d[v] + 1;
    dfs_p(u.first, v, u.second);
  }
}
void dfs(int v, int parent) {
  for (auto u : a[v]) {
    if (u.first == parent) continue;
    dfs(u.first, v);
    ans[v] += ans[u.first];
  }
  ans[v] += cnt[v];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ad[i];
  for (int i = 2; i <= n; i++) {
    int p, w;
    cin >> p >> w;
    a[i].push_back({p, w});
    a[p].push_back({i, w});
  }
  dfs_p(1, -1, 0);
  for (int i = 1; i <= n; i++) {
    int s = 0, v = i;
    long long dist = 0;
    for (int j = 24; j > -1; j--) {
      if ((1 << j) + s <= d[i] and dist + dis[j][v] <= ad[i]) {
        dist += dis[j][v];
        s += (1 << j);
        v = par[j][v];
      }
    }
    cnt[par[0][i]]++;
    cnt[par[0][v]]--;
  }
  dfs(1, -1);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
