#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int A = 30 + 1;
vector<int> v[N], c[N];
long long a[N], deep[N];
long long x, y;
int n, cnt;
long long t[N][A], d[N][A];
long long g[N], value[N];
long long s[N];
long long ans[N];
void dfs(int x, int fa) {
  if (g[x]) {
    t[x][0] = g[x];
    d[x][0] = value[x];
    for (int i = 0; t[t[x][i]][i]; ++i) {
      t[x][i + 1] = t[t[x][i]][i];
      d[x][i + 1] = d[t[x][i]][i] + d[x][i];
    }
    int now = x, noww = 0;
    bool flag = false;
    for (int i(20); i >= (0); --i) {
      if (t[now][i] && d[now][i] + noww <= a[x]) {
        noww += d[now][i];
        now = t[now][i];
        flag = true;
      }
    }
    if (flag) {
      --s[g[now]];
      ++s[g[x]];
    }
  }
  for (int i(0); i < ((int)v[x].size()); ++i) {
    int u = v[x][i];
    deep[u] = deep[x] + 1;
    dfs(u, x);
  }
}
void dfs2(int x) {
  ans[x] += s[x];
  for (int i(0); i < ((int)v[x].size()); ++i) {
    dfs2(v[x][i]);
    ans[x] += ans[v[x][i]];
  }
}
int main() {
  scanf("%d", &n);
  for (int i(1); i <= (n); ++i) scanf("%lld", a + i);
  for (int i(2); i <= (n); ++i) {
    scanf("%lld%lld", &x, &y);
    g[i] = x;
    value[i] = y;
    v[x].push_back(i), c[x].push_back(y);
  }
  memset(s, 0, sizeof s);
  cnt = 0;
  deep[1] = 0;
  dfs(1, 0);
  memset(ans, 0, sizeof ans);
  dfs2(1);
  for (int i(1); i <= (n - 1); ++i) printf("%lld ", ans[i]);
  printf("%lld\n", ans[n]);
  return 0;
}
