#include <bits/stdc++.h>
using namespace std;
const int _N = 2e5 + 11;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
long long n, a[_N], p, w, dis[_N][22], LVL[_N], LCA[_N][22], add[_N];
vector<pair<long long, long long>> adj[_N];
void dfs(int v, int p, int lvl) {
  LVL[v] = lvl;
  LCA[v][0] = p;
  for (int i = 0; i < (int)adj[v].size(); i++) {
    dfs(adj[v][i].first, v, lvl + 1);
  }
}
void constructLCA() {
  for (int lvl = 1; lvl <= 18; lvl++) {
    for (int i = 1; i <= n; i++) {
      LCA[i][lvl] = LCA[LCA[i][lvl - 1]][lvl - 1];
      dis[i][lvl] = dis[i][lvl - 1] + dis[LCA[i][lvl - 1]][lvl - 1];
    }
  }
}
long long get_dist(int v, int p) {
  long long res = 0;
  while (p > 0) {
    int diff = (int)log2(p);
    res += dis[v][diff];
    v = LCA[v][diff];
    p -= (1 << diff);
  }
  return res;
}
int get_par(int v, int p) {
  while (p > 0) {
    int diff = (int)log2(p);
    v = LCA[v][diff];
    p -= (1 << diff);
  }
  return v;
}
void solve(int v) {
  int vv = v;
  add[LCA[v][0]]++;
  for (int i = 0; i < (int)adj[v].size(); i++) {
    solve(adj[v][i].first);
  }
  long long dist = 0;
  for (int i = 20; i >= 0; i--) {
    if (dis[v][i] == 0 || dis[v][i] + dist > a[vv]) continue;
    dist += dis[v][i];
    v = LCA[v][i];
  }
  add[LCA[v][0]]--;
}
void finish(int v) {
  for (int i = 0; i < (int)adj[v].size(); i++) {
    finish(adj[v][i].first);
    add[v] += add[adj[v][i].first];
  }
}
void print() {
  for (int i = 1; i <= n; i++) cout << add[i] << " ";
  cout << '\n';
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cout << fixed;
  cout << setprecision(15);
  srand(time(NULL));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    cin >> p >> w;
    adj[p].push_back(make_pair(i + 1, w));
    dis[i + 1][0] = w;
  }
  dfs(1, 0, 1);
  constructLCA();
  solve(1);
  finish(1);
  print();
  return 0;
}
