#include <bits/stdc++.h>
using namespace std;
int n, x, y, a[200010], k, pa[200010][22], h[200010], ans[200010], num[200010],
    w[200010];
long long sum[200010];
vector<int> V[200010];
void dfs(int v) {
  for (int i = 0; i < V[v].size(); i++) {
    int u = V[v][i];
    sum[u] = sum[v] + w[u];
    dfs(u);
  }
}
void calc(int v) {
  for (int i = 0; i < V[v].size(); i++) {
    int u = V[v][i];
    calc(u);
    ans[v] += ans[u];
    ans[v] -= num[u];
  }
  ans[v]++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 2; i <= n; i++) {
    scanf("%d%d", &x, &y);
    V[x].push_back(i);
    w[i] = y;
    pa[i][0] = x;
  }
  dfs(1);
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) pa[j][i] = pa[pa[j][i - 1]][i - 1];
  for (int i = 1; i <= n; i++) {
    k = i;
    int u = 0;
    while (sum[i] - sum[pa[k][u]] <= a[i]) {
      k = pa[k][u++];
      if (!k) {
        h[i] = 1;
        break;
      }
    }
    while (u--) {
      if (sum[i] - sum[pa[k][u]] <= a[i]) {
        k = pa[k][u];
        if (!k) {
          h[i] = 1;
          break;
        }
      }
    }
    if (!h[i]) h[i] = k;
    num[k]++;
  }
  calc(1);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i] - 1);
}
