#include <bits/stdc++.h>
using namespace std;
vector<long long> adia[200010];
long long noduri[200010];
long long stramos[200010][20], g_str[200010][20];
long long smen[200010];
void make_stramosi(long long nod);
void calc(long long nod, long long ramas, long long l = 19);
void dfs(long long nod);
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> noduri[i];
  for (long long i = 2; i <= n; i++) {
    cin >> stramos[i][0] >> g_str[i][0];
    adia[stramos[i][0]].push_back(i);
  }
  make_stramosi(1);
  dfs(1);
  for (long long i = 1; i <= n; i++) cout << smen[i] << ' ';
  return 0;
}
void dfs(long long nod) {
  calc(nod, noduri[nod]);
  smen[stramos[nod][0]]++;
  for (auto i : adia[nod]) dfs(i);
  smen[stramos[nod][0]] += smen[nod];
}
void calc(long long nod, long long ramas, long long l) {
  while (l >= 0) {
    if (g_str[nod][l] <= ramas) {
      ramas -= g_str[nod][l];
      nod = stramos[nod][l];
    }
    l--;
  }
  nod = stramos[nod][0];
  smen[nod]--;
}
void make_stramosi(long long nod) {
  for (long long i = 1; i < 20; i++) {
    stramos[nod][i] = stramos[stramos[nod][i - 1]][i - 1];
    g_str[nod][i] = g_str[stramos[nod][i - 1]][i - 1] + g_str[nod][i - 1];
  }
  for (auto i : adia[nod]) make_stramosi(i);
}
