#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, long long> > > g;
const int N = 2 * 100000 + 10;
int par[19][N];
long long dist[19][N];
void dfs(int u, int p) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (v != p) {
      par[0][v] = u;
      dist[0][v] = g[u][i].second;
      dfs(v, u);
    }
  }
}
int get(int u, long long c) {
  for (int j = 18; j >= 0; j--) {
    if (dist[j][u] <= c) {
      c -= dist[j][u];
      u = par[j][u];
    }
  }
  return par[0][u];
}
int acc[N];
vector<int> res;
int go(int u, int p) {
  int c = acc[u];
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (v != p) c += go(v, u);
  }
  res[u] = c;
  return c;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  g.resize(n);
  for (int i = 1; i < n; i++) {
    int p, w;
    scanf("%d%d", &p, &w);
    g[p - 1].push_back(make_pair(i, w));
  }
  for (int j = 0; j < 19; j++) {
    for (int i = 0; i < n; i++) par[j][i] = -1, dist[j][i] = 1e15;
  }
  dfs(0, -1);
  for (int j = 1; j < 19; j++) {
    for (int i = 0; i < n; i++) {
      if (par[j - 1][i] != -1) {
        par[j][i] = par[j - 1][par[j - 1][i]];
        dist[j][i] = dist[j - 1][i] + dist[j - 1][par[j - 1][i]];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (par[0][i] != -1) acc[par[0][i]]++;
    int u = get(i, a[i]);
    if (u != -1) acc[u]--;
  }
  res.resize(n);
  go(0, -1);
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
