#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
bool mini(A &a, const B b) {
  return a > b ? (a = b, 1) : 0;
}
template <class A, class B>
bool maxi(A &a, const B b) {
  return a < b ? (a = b, 1) : 0;
}
const long long maxN = 2e5 + 5;
long long n, a[maxN], p[maxN], w[maxN], res[maxN], h[maxN], num[maxN], v[maxN],
    d[maxN], cnt, idx[maxN], id[maxN], it[maxN << 2];
vector<pair<long long, long long> > adj[maxN];
void upd(const long long q, const long long i = 1, const long long l = 1,
         const long long r = n) {
  if (l > r || r < q || q < l) return;
  it[i]++;
  if (l == r) return;
  const long long m = l + r >> 1;
  upd(q, i << 1, l, m);
  upd(q, i << 1 | 1, m + 1, r);
}
long long get(long long ql, long long qr, long long i = 1, long long l = 1,
              long long r = n) {
  if (l > r || qr < l || r < ql) return 0;
  if (ql <= l && r <= qr) return it[i];
  long long m = l + r >> 1;
  return get(ql, qr, i << 1, l, m) + get(ql, qr, i << 1 | 1, m + 1, r);
}
long long dfs(const long long u) {
  num[u] = ++cnt;
  v[u] = a[u] - h[u];
  long long v, x;
  for (vector<pair<long long, long long> >::iterator i = adj[u].begin();
       i != adj[u].end(); i++) {
    x = i->first;
    v = i->second;
    h[v] = h[u] + x;
    d[u] += dfs(v) + 1;
  }
  return d[u];
}
bool cmp(const long long &l, const long long &r) { return v[l] < v[r]; }
bool cmp2(const long long &l, const long long &r) { return h[l] < h[r]; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = (1), _b = (n); i <= (_b); i++) {
    cin >> a[i];
    idx[i] = id[i] = i;
  }
  for (long long i = (2), _b = (n); i <= (_b); i++) {
    cin >> p[i] >> w[i];
    adj[p[i]].push_back(pair<long long, long long>(w[i], i));
  }
  dfs(1);
  sort(idx + 1, idx + 1 + n, cmp);
  sort(id + 1, id + 1 + n, cmp2);
  long long j, x = n;
  for (long long i = (1), _b = (n); i <= (_b); i++) {
    j = id[i];
    if (j == 10) {
      cerr << "";
    }
    for (; x > 0 && v[idx[x]] + h[j] >= 0; x--) upd(num[idx[x]]);
    res[j] = get(num[j] + 1, num[j] + d[j]);
  }
  for (long long i = (1), _b = (n); i <= (_b); i++) cout << res[i] << ' ';
  cout << '\n';
  return 0;
}
