#include <bits/stdc++.h>
using namespace std;
long long int a[200005];
vector<long long int> g[200005];
vector<long long int> c[200005];
multiset<long long int> st[200005];
long long int idx[200005], toAdd[200005], ans[200005];
void mergeTree(long long int id1, long long int id2) {
  multiset<long long int>::iterator it;
  long long int x;
  for (it = st[id2].begin(); it != st[id2].end(); it++) {
    x = *it + toAdd[id2] - toAdd[id1];
    st[id1].insert(x);
  }
  return;
}
void dfs(long long int u) {
  idx[u] = u;
  long long int i, j, k, mx;
  mx = st[idx[u]].size();
  long long int id = idx[u];
  for (i = 0; i < g[u].size(); i++) {
    long long int v = g[u][i];
    dfs(v);
    if (st[idx[v]].size() > mx) {
      mx = st[idx[v]].size();
      id = idx[v];
    }
    toAdd[idx[v]] -= c[u][i];
  }
  idx[u] = id;
  for (i = 0; i < g[u].size(); i++) {
    long long int v = g[u][i];
    if (id != idx[v]) mergeTree(id, idx[v]);
    st[id].insert((a[v] - c[u][i]) - toAdd[id]);
  }
  multiset<long long int>::iterator it;
  while (!st[id].empty()) {
    it = st[id].begin();
    if ((*it + toAdd[id]) < 0)
      st[id].erase(it);
    else
      break;
  }
  ans[u] = (long long int)st[id].size();
  return;
}
int main() {
  long long int i, j, k, l, m, n;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 2; i <= n; i++) {
    scanf("%lld %lld", &k, &l);
    g[k].push_back(i);
    c[k].push_back(l);
  }
  memset(toAdd, 0, sizeof(toAdd));
  dfs(1);
  for (i = 1; i <= n; i++) {
    printf("%lld", ans[i]);
    if (i < n)
      printf(" ");
    else
      printf("\n");
  }
  return 0;
}
