#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> g;
vector<array<long long, 38>> p;
const long long x = 19;
vector<long long> dp;
long long dfs1(long long u) {
  for (long long v : g[u]) dp[u] += dfs1(v);
  return dp[u];
}
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  long long n;
  cin >> n;
  g.resize(n), p.resize(n), dp.resize(n, 0);
  long long a[n];
  for (long long &i : a) cin >> i;
  p[0][0] = p[0][x] = 0;
  for (long long i = 1; i < n; ++i) {
    cin >> p[i][0] >> p[i][x], --p[i][0];
    g[p[i][0]].push_back(i);
  }
  for (long long i = 1; i < x; ++i)
    for (long long u = 0; u < n; ++u)
      p[u][i] = p[p[u][i - 1]][i - 1],
      p[u][i + x] = p[u][i + x - 1] + p[p[u][i - 1]][i + x - 1];
  for (long long i = 1; i < n; ++i) {
    long long sum = 0, u = i;
    for (long long j = x - 1; j >= 0; --j)
      while (u and sum + p[u][j + x] <= a[i]) sum += p[u][j + x], u = p[u][j];
    ++dp[p[i][0]];
    if (u) --dp[p[u][0]];
  }
  dfs1(0);
  for (long long i : dp) cout << i << ' ';
}
