#include <bits/stdc++.h>
const int maxn = 3e5;
std::vector<std::pair<int, int> > G[maxn];
int n, a[maxn], sum[maxn], ans[maxn], delta;
long long S[maxn], dis[maxn];
void DFS(int x, int dep) {
  S[dep] = dis[x];
  for (int i = 0; i < G[x].size(); ++i)
    dis[G[x][i].first] = G[x][i].second + dis[x], DFS(G[x][i].first, dep + 1);
  --sum[std::lower_bound(S, S + dep, dis[x] - a[x]) - S - 1];
  ++sum[dep - 1];
  sum[dep - 1] += ans[x] = sum[dep];
  sum[dep] = 0;
}
int main() {
  int i, x, y;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", a + i);
  for (i = 1; i < n; ++i)
    scanf("%d%d", &x, &y), G[x].push_back(std::make_pair(i + 1, y));
  DFS(1, 1);
  for (i = 1; i <= n; ++i) printf("%d ", ans[i]);
}
