#include <bits/stdc++.h>
using namespace std;
vector<int> tab[200010];
long long n, v[200010], j[20][200010], s[20][200010], miotla[200010], ver, x, y;
bool met[200010];
void dfs(int w) {
  met[w] = 1;
  for (int a = 0; a < tab[w].size(); a++) {
    if (!met[tab[w][a]]) {
      dfs(tab[w][a]);
      miotla[w] += miotla[tab[w][a]];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int a = 1; a <= n; a++) cin >> v[a];
  for (int a = 1; a < n; a++) {
    cin >> x >> y;
    j[0][a + 1] = x;
    s[0][a + 1] = y;
    tab[x].push_back(a + 1);
    tab[a + 1].push_back(x);
  }
  for (int a = 1; a <= 18; a++)
    for (int b = 1; b <= n; b++)
      j[a][b] = j[a - 1][j[a - 1][b]],
      s[a][b] = s[a - 1][b] + s[a - 1][j[a - 1][b]];
  for (int a = 1; a <= n; a++) {
    ver = a;
    for (int b = 18; b >= 0; b--) {
      if (v[a] >= s[b][ver]) {
        v[a] -= s[b][ver];
        ver = j[b][ver];
      }
    }
    miotla[a]++;
    miotla[j[0][ver]]--;
  }
  dfs(1);
  for (int a = 1; a <= n; a++) cout << miotla[a] - 1 << " ";
  return 0;
}
