#include <bits/stdc++.h>
const int X = 500000;
using namespace std;
int n, idx[X], pcnt;
long long a[X], w[X], pre[X], d[X], ans[X];
vector<int> g[X];
void Dfs(int u) {
  ans[u] = 0;
  int id = lower_bound(pre, pre + pcnt + 1, pre[pcnt] - a[u]) - pre;
  d[idx[id - 1]]--;
  d[idx[pcnt - 1]]++;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    pre[pcnt + 1] = pre[pcnt] + w[v];
    idx[pcnt + 1] = v;
    pcnt++;
    Dfs(v);
    ans[u] += ans[v];
    pcnt--;
  }
  ans[u] += d[u];
}
void Dfs2(int u) {
  ans[u] = d[u];
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    Dfs2(v);
    ans[u] += ans[v];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int v = 2; v <= n; v++) {
    int u;
    scanf("%d%lld", &u, &w[v]);
    g[u].push_back(v);
  }
  idx[0] = 1;
  Dfs(1);
  for (int i = 1; i <= n; i++) printf("%lld ", ans[i]);
  puts(" ");
}
