#include <bits/stdc++.h>
using namespace std;
vector<long long> al;
vector<long long> ans;
vector<long long> par;
vector<long long> cnt;
vector<vector<pair<long long, long long>>> adj;
vector<long long> stacko;
void dfs(long long x, long long d, vector<long long>& fa) {
  for (auto e : adj[x]) {
    fa.push_back(e.second);
    if (fa.size() > 1) fa[fa.size() - 1] += fa[fa.size() - 2];
    stacko.push_back(e.first);
    long long id =
        lower_bound(fa.begin(), fa.end() - 1, fa.back() - al[e.first]) -
        fa.begin();
    if (par[stacko[id]] >= 0) ans[par[stacko[id]]]++;
    dfs(e.first, d + 1, fa);
    fa.pop_back();
    stacko.pop_back();
    ans[x] += ans[e.first];
    cnt[x] += cnt[e.first] + 1;
  }
}
void run() {
  long long n;
  cin >> n;
  al.resize(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> al[i];
  adj.resize(n + 1);
  ans.resize(n + 1, 0);
  cnt.resize(n + 1, 0);
  par.resize(n + 1, 0);
  for (int i = 2; i <= n; i++) {
    long long x, w;
    cin >> x >> w;
    adj[x].push_back(make_pair(i, w));
    par[i] = x;
  }
  vector<long long> fa;
  fa.push_back(0);
  stacko.push_back(0);
  dfs(1, 0, fa);
  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << " ";
    cout << cnt[i] - ans[i];
  }
  cout << endl;
}
int main() { run(); }
