#include <bits/stdc++.h>
using namespace std;
ifstream in("dap.in");
const int dim = 200005;
int n, ans[dim];
long long int dist[dim], a[dim], val[dim];
vector<pair<int, long long int> > vec[dim];
priority_queue<long long int> pq[dim];
void DFS(int nod, int parent, long long int cost) {
  dist[nod] = dist[parent] + cost;
  for (int j = 0; j < vec[nod].size(); j++) {
    int fiu = vec[nod][j].first;
    int cost = vec[nod][j].second;
    if (fiu != parent) {
      DFS(fiu, nod, cost);
    }
  }
}
priority_queue<long long int> *DFS_2(int nod, int parent) {
  priority_queue<long long int> *pq1 = &pq[nod];
  (*pq1).push(val[nod]);
  for (int j = 0; j < vec[nod].size(); j++) {
    int fiu = vec[nod][j].first;
    if (fiu != parent) {
      priority_queue<long long int> *pq2 = DFS_2(fiu, nod);
      if ((*pq1).size() < (*pq2).size()) {
        swap(pq1, pq2);
      }
      while (!(*pq2).empty()) {
        (*pq1).push((*pq2).top());
        (*pq2).pop();
      }
      while (!(*pq1).empty() && (*pq1).top() > dist[nod]) {
        (*pq1).pop();
      }
      ans[nod] = (*pq1).size();
      if (ans[nod] != 0) ans[nod]--;
    }
  }
  return pq1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1, p, w; i < n; i++) {
    cin >> p >> w;
    vec[i + 1].push_back({p, w});
    vec[p].push_back({i + 1, w});
  }
  DFS(1, 0, 1);
  for (int i = 1; i <= n; i++) {
    val[i] = dist[i] - a[i];
  }
  DFS_2(1, 0LL);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
