#include <bits/stdc++.h>
long long poww(long long x, long long y) {
  long long res = 1;
  x %= 1000000007;
  assert(y >= 0);
  for (; y; y >>= 1) {
    if (y & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
  }
  return res;
}
using namespace std;
long long int c[200005], p[200005], ans[200005], P[200005][20], a[200005],
    dis[200005];
map<pair<int, int>, int> M;
bool vis[200005];
vector<int> v[200005];
void dfs(int x, long long int sum) {
  dis[x] = sum;
  for (int i = 0; i < v[x].size(); ++i)
    if (!vis[v[x][i]]) {
      vis[v[x][i]] = true;
      dfs(v[x][i], sum + M[make_pair(x, v[x][i])]);
    }
}
void build() {
  memset(P, -1, sizeof P);
  for (int j = 0; j <= 18; ++j)
    for (int i = 0; i < 200005; ++i)
      if (!j)
        P[i][j] = p[i];
      else if (P[i][j - 1] != -1)
        P[i][j] = P[P[i][j - 1]][j - 1];
}
int fnc(int x, int au) {
  int px;
  if (au - (dis[x] - dis[P[x][0]]) < 0) return P[x][0];
  for (int i = 1; i < 19; ++i) {
    px = P[x][i];
    if (px == -1 && p[x] == 1) return 0;
    if (px == -1 || dis[x] - dis[px] > au)
      return fnc(P[x][i - 1], au - (dis[x] - dis[P[x][i - 1]]));
    if (px == 1) return 0;
  }
}
int recur(int x) {
  long long sum = c[x];
  for (int i = 0; i < v[x].size(); ++i) sum += recur(v[x][i]);
  ans[x] = sum;
  return sum;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, x, y, i, j, k, l;
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> a[i];
  p[1] = -1;
  for (i = 2; i <= n; ++i) {
    cin >> x >> y;
    p[i] = x;
    v[x].push_back(i);
    M[make_pair(x, i)] = y;
    M[make_pair(i, x)] = y;
  }
  build();
  vis[1] = true;
  dfs(1, 0);
  for (i = 2; i <= n; ++i) {
    c[p[i]]++;
    c[fnc(i, a[i])]--;
  }
  memset(vis, false, sizeof vis);
  vis[1] = true;
  ans[1] = recur(1);
  for (i = 1; i <= n; ++i) cout << ans[i] << " ";
  return 0;
}
