#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long n, a[maxn], k, ans[maxn];
vector<long long> v[maxn], w[maxn];
bool mark[maxn];
priority_queue<long long> s[maxn];
map<int, int> mp;
void dfs(int root, long long dis, int par) {
  mark[root] = true;
  for (int i = 0; i < (int)v[root].size(); i++)
    if (!mark[v[root][i]]) {
      dfs(v[root][i], dis + w[root][i], root);
      while (!s[mp[v[root][i]]].empty()) {
        if (s[mp[v[root][i]]].top() > dis)
          s[mp[v[root][i]]].pop();
        else
          break;
      }
    }
  if (root != 1 && (int)v[root].size() == 1) {
    mp[root] = k++;
    s[mp[root]].push(dis - a[root]);
    return;
  }
  pair<long long, long long> maxi = pair<long long, long long>(0, 10000000);
  for (int i = 0; i < (int)v[root].size(); i++)
    if (v[root][i] != par)
      maxi = max(maxi, pair<long long, long long>(s[mp[v[root][i]]].size(),
                                                  v[root][i]));
  if (maxi.second != 10000000) {
    for (int i = 0; i < (int)v[root].size(); i++)
      if (v[root][i] != par && mp[v[root][i]] != mp[maxi.second]) {
        while (!s[mp[v[root][i]]].empty()) {
          long long tmp = s[mp[v[root][i]]].top();
          s[mp[v[root][i]]].pop();
          s[mp[maxi.second]].push(tmp);
        }
      }
    mp[root] = mp[maxi.second];
    ans[root] = s[mp[root]].size();
    s[mp[root]].push(dis - a[root]);
    return;
  }
  mp[root] = k++;
  s[mp[root]].push(dis - a[root]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    long long p, wei;
    cin >> p >> wei;
    v[i].push_back(p);
    v[p].push_back(i);
    w[i].push_back(wei);
    w[p].push_back(wei);
  }
  dfs(1, 0, -1);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
