#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const long double EPS = 1e-12;
const int INF = 1e9 + 10;
const long long LINF = 9000ll * 1000 * 1000 * 1000 * 1000 * 1000 + 100;
const int MN = 2e5 + 10;
const int LG = 20;
int arr[MN];
vector<pair<int, int> > adj[MN];
int n;
long long d[LG][MN];
int par[LG][MN];
int sz[MN], col[MN];
void input() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 1; i < n; ++i) {
    int t, w;
    cin >> t >> w;
    adj[i].push_back(make_pair(t - 1, w)),
        adj[t - 1].push_back(make_pair(i, w));
  }
}
void dfs1(int s, int pr) {
  for (int i = 0; i < ((int)(adj[s]).size()); ++i) {
    int v = adj[s][i].first, e = adj[s][i].second;
    if (v == pr) continue;
    par[0][v] = s, d[0][v] = e;
    for (int i = 1; i < LG; ++i)
      if (~par[i - 1][v]) {
        par[i][v] = par[i - 1][par[i - 1][v]];
        d[i][v] = min(LINF, d[i - 1][v] + d[i - 1][par[i - 1][v]]);
      }
    dfs1(v, s);
  }
}
void prep() {
  for (int i = 0; i < n; ++i) {
    int t = arr[i], cur = i;
    for (int j = LG - 1; ~j; --j) {
      if (t >= d[j][cur]) t -= d[j][cur], cur = par[j][cur];
    }
    if (~par[0][i]) ++col[par[0][i]];
    if (~par[0][cur]) --col[par[0][cur]];
  }
}
void dfs2(int s, int pr) {
  sz[s] = col[s];
  for (int i = 0; i < ((int)(adj[s]).size()); ++i) {
    int v = adj[s][i].first;
    if (v == pr) continue;
    dfs2(v, s);
    sz[s] += sz[v];
  }
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  input();
  memset(par, -1, sizeof par);
  for (int i = 0; i < LG; ++i)
    for (int j = 0; j < n; ++j) d[i][j] = LINF;
  dfs1(0, -1);
  prep();
  dfs2(0, -1);
  for (int i = 0; i < n; ++i) cout << sz[i] << ' ';
  cout << '\n';
  return 0;
}
