#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int cost[200005] = {};
long long int a[200005] = {};
long long int ans[200005] = {};
long long int b[200005] = {};
long long int p, c;
vector<int> e[200005];
long long int dfs(long long int x) {
  long long int l = 0;
  for (int i = 0; i < (e[x].size()); i++) {
    l += dfs(e[x][i]) + b[e[x][i]];
  }
  ans[x] += l;
  return l;
}
int par[20][200005];
long long int dist[200005];
void f(long long int x, long long int d) {
  dist[x] = d;
  for (int i = 0; i < (e[x].size()); i++) {
    f(e[x][i], d + cost[e[x][i]]);
  }
}
int main() {
  long long int n;
  cin >> n;
  for (int i = 0; i < (n); i++) scanf("%ld", &a[i]);
  par[0][0] = -1;
  for (int i = 0; i < (n - 1); i++) {
    scanf("%ld %ld", &p, &c);
    p--;
    par[0][i + 1] = p;
    cost[i + 1] = c;
    e[p].push_back(i + 1);
  }
  for (int i = 0; i < (19); i++)
    for (int j = 0; j < (n); j++) {
      par[i + 1][j] = par[i][par[i][j]];
    }
  f(0, 0);
  for (int i = 0; i < (n); i++) {
    long long int d = dist[i];
    long long int at = a[i];
    long long int now = i;
    for (int j = (20) - 1; j >= 0; j--) {
      if (par[j][now] == -1) {
        continue;
      }
      if (-dist[par[j][now]] + dist[now] <= at) {
        at -= dist[now] - dist[par[j][now]];
        now = par[j][now];
      }
    }
    b[i]++;
    b[now]--;
  }
  dfs(0);
  for (int i = 0; i < (n); i++) cout << ans[i] << ' ';
}
