#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
vector<pair<int, int> > V[N];
vector<long long> cur;
vector<int> pos;
long long c;
int p, A[N], n, e, sol[N], par[N];
void Dfs(int x) {
  pos.push_back(x);
  cur.push_back(c);
  for (int i = 0; i < V[x].size(); i++) {
    c += (long long)V[x][i].second;
    Dfs(V[x][i].first);
    sol[x] += (sol[V[x][i].first] + 1);
  }
  int p =
      lower_bound(cur.begin(), cur.end(), c - (long long)A[x]) - cur.begin();
  if (p) {
    p--;
    sol[pos[p]]--;
  }
  cur.pop_back(), pos.pop_back();
  c -= (long long)par[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 2; i <= n; i++) {
    scanf("%d %d", &p, &e);
    V[p].push_back({i, e});
    par[i] = e;
  }
  Dfs(1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", sol[i]);
  }
  return 0;
}
