#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, a[200005];
vector<long long> adj[200005], W[200005];
vector<long long> stk, sm, pth;
long long ans[200005];
long long _upper_bound(long long val) {
  long long l = 0, r = stk.size() - 1;
  while (1) {
    if (l == r) return l;
    if (l == r - 1) {
      if (val >= stk[r] + sm[stk.size() - 1] - sm[r]) return l;
      return r;
    }
    if (val >= stk[(l + r >> 1)] + sm[stk.size() - 1] - sm[(l + r >> 1)])
      r = (l + r >> 1);
    else
      l = (l + r >> 1);
  }
}
void dfs(long long node, long long par, long long wt) {
  stk.push_back(wt);
  sm.push_back(wt + (sm.size() > 0 ? sm[sm.size() - 1] : 0));
  pth.push_back(node);
  ans[pth[_upper_bound(a[node])]]--;
  for (long long i = 0; i < adj[node].size(); i++) {
    long long nxt = adj[node][i];
    dfs(nxt, node, W[node][i]);
    ans[node] += ans[nxt] + 1;
  }
  pth.pop_back();
  sm.pop_back();
  stk.pop_back();
  return;
}
void solve() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1; i < n; i++) {
    long long p, w;
    scanf("%lld %lld", &p, &w);
    adj[p].push_back(i + 1);
    W[p].push_back(w);
  }
  pth.push_back(0);
  dfs(1, 0, 0);
  for (long long i = 1; i <= n; i++) printf("%lld ", ans[i]);
  return;
}
int main() {
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
