#include <bits/stdc++.h>
using namespace std;
void ga(int N, long long* A) {
  for (int i(0); i < N; i++) scanf("%lld", A + i);
}
vector<pair<long long, long long> > g[(1 << 19)];
long long P[(1 << 19)] = {-1}, N, A[(1 << 19)], O[(1 << 19)], T[(1 << 19)], a,
                  b;
long long dfs(long long u, long long d, long long c) {
  P[d] = P[d - 1] + c, T[d] = 0;
  long long S = 0, r = upper_bound(P, P + d, P[d] - A[u] - 1) - P - 1;
  if (r > 0) ++T[r];
  for (auto& h : g[u]) S += dfs(h.first, d + 1, h.second);
  O[u] = S -= T[d];
  return S + 1;
}
int main(void) {
  scanf("%lld", &N), ga(N, A);
  for (int k(1); k < N; k++)
    scanf("%lld%lld", &a, &b), g[--a].push_back({k, b});
  dfs(0, 1, 0);
  for (int i(0); i < N; i++) printf("%lld%c", O[i], i + 1 == N ? 10 : 32);
  return 0;
}
