#include <bits/stdc++.h>
using namespace std;
long long n, a[((long long)201 * 1000)], prt[((long long)201 * 1000)],
    ans[((long long)201 * 1000)];
vector<pair<long long, long long> > e[((long long)201 * 1000)];
long long dis[((long long)201 * 1000)],
    par[((long long)20)][((long long)201 * 1000)],
    dist[((long long)20)][((long long)201 * 1000)];
void pre_dfs(long long x) {
  for (int i = 1; i < ((long long)20); i++)
    par[i][x] = par[i - 1][par[i - 1][x]],
    dist[i][x] = dist[i - 1][x] + dist[i - 1][par[i - 1][x]];
  for (auto u : e[x])
    par[0][u.first] = x, dis[u.first] = dis[x] + 1, dist[0][u.first] = u.second,
    pre_dfs(u.first);
}
long long iPar(long long x, long long num) {
  for (int i = 0; i < ((long long)20); i++)
    if ((num & (1 << i))) x = par[i][x];
  return x;
}
long long iSum(long long x, long long num) {
  long long res = 0;
  for (int i = 0; i < ((long long)20); i++)
    if ((num & (1 << i))) res += dist[i][x], x = par[i][x];
  return res;
}
void dfs(long long x) {
  for (auto u : e[x]) dfs(u.first), prt[x] += prt[u.first];
  ans[x] = prt[x];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    long long x, w;
    cin >> x >> w;
    e[x].push_back({i, w});
  }
  pre_dfs(1);
  for (int i = 1; i <= n; i++) {
    long long l = 0, r = dis[i] + 1;
    while (l < r - 1) {
      long long mid = (l + r) / 2;
      if (iSum(i, mid) <= a[i])
        l = mid;
      else
        r = mid;
    }
    prt[par[0][i]]++;
    prt[par[0][iPar(i, l)]]--;
  }
  dfs(1);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
