#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)-1e18;
const int N = 200 * 1000 + 100;
vector<int> g[N];
vector<int> w[N];
vector<pair<long long, long long> > cur;
long long add[N];
long long ans[N];
int a[N];
long long dfs2(int v) {
  ans[v] = add[v];
  for (int i = 0; i < g[v].size(); i++) ans[v] += dfs2(g[v][i]);
  return ans[v];
}
void dfs(int v, int par, long long h) {
  if (v != par) {
    long long dist = h - a[v];
    vector<pair<long long, long long> >::iterator it = lower_bound(
        cur.begin(), cur.end(), pair<long long, long long>(dist, INF));
    add[par]++;
    if (it != cur.begin()) {
      it--;
      add[it->second]--;
    }
  }
  cur.push_back(pair<long long, long long>(h, v));
  for (int i = 0; i < g[v].size(); i++) dfs(g[v][i], v, h + w[v][i]);
  cur.pop_back();
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    int p, l;
    cin >> p >> l;
    p--;
    g[p].push_back(i);
    w[p].push_back(l);
  }
  dfs(0, 0, 0);
  dfs2(0);
  for (long long i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
