#include <bits/stdc++.h>
using namespace std;
const int MX = 200009, MXL = 18;
vector<pair<int, int> > v[MX];
int n, QN, depth[MX], par[MXL][MX];
long long sum[MX];
void Pdfs(int x, int p) {
  int nxt, C, sz = v[x].size();
  for (int j = 0; j < sz; j++) {
    nxt = v[x][j].first;
    if (nxt == p) continue;
    depth[nxt] = depth[x] + 1;
    par[0][nxt] = x;
    sum[nxt] = sum[x] + v[x][j].second;
    Pdfs(nxt, x);
  }
}
void process() {
  for (int j = 1; j < MXL; j++)
    for (int i = 1; i <= n; i++) par[j][i] = par[j - 1][par[j - 1][i]];
}
int Kth(int x, int K) {
  int node = x;
  for (int j = 0; j < MXL; j++)
    if ((K & (1 << j))) node = par[j][node];
  return node;
}
int coef[MX];
void nk7(int x, int p) {
  for (auto pp : v[x]) {
    int nxt = pp.first;
    if (nxt == p) continue;
    nk7(nxt, x);
    coef[x] += coef[nxt];
  }
}
int V[MX];
int main() {
  scanf("%d", &n);
  for (int j = 1; j <= n; j++) scanf("%d", &V[j]);
  for (int j = 2; j <= n; j++) {
    int x, c;
    scanf("%d %d", &x, &c);
    v[x].push_back({j, c});
  }
  depth[1] = 1;
  Pdfs(1, -1);
  process();
  for (int x = 1; x <= n; x++) {
    coef[x]++;
    int cur = x;
    for (int log = MXL - 1; log >= 0; log--) {
      if (par[log][cur] == 0) continue;
      int pp = par[log][cur];
      if (sum[x] - sum[pp] <= V[x]) cur = pp;
    }
    coef[par[0][cur]]--;
  }
  nk7(1, -1);
  for (int j = 1; j <= n; j++) printf("%d\n", coef[j] - 1);
}
