#include <bits/stdc++.h>
using namespace std;
void smain();
int main() {
  ios_base::sync_with_stdio(0);
  smain();
  return 0;
}
long long n;
vector<pair<long long, long long> > edges[200005];
long long t[200005];
long long sum(long long x) {
  long long result = 0;
  for (; x >= 0; x = (x & (x + 1)) - 1) result += t[x];
  return result;
}
void upd(long long i, long long delta) {
  for (; i < n; i = (i | (i + 1))) t[i] += delta;
}
long long sum(long long a, long long b) { return sum(b) - sum(a - 1); }
long long a[200005], d[200005];
long long l[200005], r[200005], timer = 0;
void dfs(long long v, long long p = -1) {
  l[v] = timer++;
  for (auto i : edges[v])
    if (i.first != p) {
      d[i.first] = d[v] + i.second;
      dfs(i.first, v);
    }
  r[v] = timer;
}
void smain() {
  for (; cin >> n;) {
    for (long long i = 0; i < n; i++) edges[i].clear();
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n - 1; i++) {
      long long u = i + 1, v, w;
      cin >> v >> w;
      v -= 1;
      edges[u].emplace_back(v, w);
      edges[v].emplace_back(u, w);
    }
    timer = 0;
    dfs(0);
    vector<pair<long long, long long> > q(n);
    vector<pair<long long, long long> > f(n);
    for (long long i = 0; i < n; i++) q[i] = {d[i], i}, f[i] = {d[i] - a[i], i};
    sort(q.begin(), q.end());
    sort(f.begin(), f.end());
    long long i = 0, j = 0;
    vector<long long> res(n);
    memset(t, 0, sizeof(long long) * n);
    for (; i < n; ++i) {
      for (; j < n && f[j].first <= q[i].first; ++j) {
        upd(l[f[j].second], 1);
      }
      long long v = q[i].second;
      res[v] = sum(l[v] + 1, r[v] - 1);
    }
    for (long long v = 0; v < n; v++) cout << res[v] << ' ';
    cout << endl;
  }
}
