#include <bits/stdc++.h>
using namespace std;
int a[300005];
long long dis[300005];
vector<int> tree[3000005];
int ans[300005];
int stkid[300005];
long long stk[3000005];
void dfs(int num, int deep) {
  stkid[deep] = num;
  stk[deep] = stk[deep - 1] + dis[num];
  long long *x = lower_bound(stk, stk + deep + 1, stk[deep] - a[num]);
  --ans[stkid[lower_bound(stk, stk + deep + 1, stk[deep] - a[num]) - stk - 1]];
  ans[num]++;
  for (int i = 0; i < tree[num].size(); ++i) {
    dfs(tree[num][i], deep + 1);
    ans[num] += ans[tree[num][i]];
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, i;
  memset(ans, 0, sizeof(ans));
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> a[i];
  stk[0] = 0;
  for (i = 2; i <= n; ++i) {
    int temp;
    cin >> temp;
    tree[temp].push_back(i);
    cin >> dis[i];
  }
  dfs(1, 1);
  for (i = 1; i <= n; ++i) {
    cout << ans[i] - 1 << " ";
  }
  return 0;
}
