#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a, ans, ST;
vector<vector<pair<int, int> > > edg;
void update(int l, int r, int val, int v = 1, int tl = 0, int tr = n - 1) {
  if (l > r) return;
  if (l == tl && r == tr) {
    ST[v] += val;
  } else {
    int tm = (tl + tr) / 2;
    update(l, min(tm, r), val, 2 * v, tl, tm);
    update(max(l, tm + 1), r, val, 2 * v + 1, tm + 1, tr);
  }
}
int get(int id, int v = 1, int tl = 0, int tr = n - 1) {
  if (tl == tr) {
    return ST[v];
  }
  int tm = (tl + tr) / 2;
  if (id <= tm) {
    return ST[v] + get(id, 2 * v, tl, tm);
  } else {
    return ST[v] + get(id, 2 * v + 1, tm + 1, tr);
  }
}
void dfs(int v, deque<long long int>& dist, long long int total) {
  int sz = dist.size();
  int l = 0;
  int r = sz - 1;
  while (l < r) {
    int m = (l + r) / 2;
    if (total - dist[m] <= a[v]) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  r = sz - 2;
  if (l <= r) {
    update(l, r, 1);
  }
  for (auto u : edg[v]) {
    dist.push_back(total + u.second);
    dfs(u.first, dist, total + u.second);
    int added = get(sz - 1);
    ans[v] += added;
    update(sz - 1, sz - 1, -added);
    dist.pop_back();
  }
}
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  edg.resize(n);
  int p, w;
  for (int i = 0; i < n - 1; ++i) {
    cin >> p >> w;
    p--;
    edg[p].push_back({i + 1, w});
  }
  p = 1;
  while (p < n) p <<= 1;
  ST.resize(2 * p, 0);
  ans.resize(n, 0);
  deque<long long int> tmp(1, 0);
  dfs(0, tmp, 0);
  for (auto cnt : ans) {
    cout << cnt << ' ';
  }
  return 0;
}
