#include <bits/stdc++.h>
const double PI = 2.0 * acos(0);
using namespace std;
long long int ar[1000000], dp[1000000], vis[1000000], dis[1000000],
    par[1000000], ans[300000];
vector<long long int> Ed[300000], cst[300000];
void dfs(int u, int lv) {
  vis[u] = 1;
  if (lv > 0) {
    int lw = 0, hi = lv - 1, mid;
    while (lw <= hi) {
      mid = (lw + hi) / 2;
      long long int val = dis[lv - 1];
      if (mid > 0) val -= dis[mid - 1];
      if (val <= ar[u - 1]) {
        if (mid > 0) {
          val = dis[lv - 1];
          if (mid - 1 > 0) val -= dis[mid - 2];
          if (val <= ar[u - 1]) {
            hi = mid - 1;
          } else
            break;
        } else
          break;
      } else {
        lw = mid + 1;
      }
    }
    if (lw <= hi) {
      dp[par[mid]]--;
      dp[u]++;
    }
  }
  int i, j = Ed[u].size(), v;
  for (i = 0; i < j; i++) {
    v = Ed[u][i];
    if (vis[v] == 0) {
      dis[lv] = cst[u][i];
      if (lv > 0) dis[lv] = dis[lv] + dis[lv - 1];
      par[lv] = u;
      dfs(v, lv + 1);
      ans[u] = ans[u] + dp[v];
    }
  }
  if (lv > 0) {
    dp[par[lv - 1]] += dp[u];
  }
}
int main() {
  long long int i, j, k, l, t, cs = 1, r = 1, s, m, n, a, b, c, d, e, f, g, h,
                               u, v;
  scanf("%I64d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &ar[i]);
  }
  for (i = 0; i < n - 1; i++) {
    scanf("%I64d %I64d", &u, &v);
    Ed[u].push_back(i + 2);
    cst[u].push_back(v);
  }
  memset(vis, 0, sizeof(vis));
  memset(dp, 0, sizeof(dp));
  memset(ans, 0, sizeof(ans));
  dfs(1, 0);
  for (i = 0; i < n; i++) {
    printf("%I64d ", ans[i + 1]);
  }
  return 0;
}
