#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<pair<int, int> > > adjList;
int arr[200001];
int cnt[200001];
priority_queue<pair<long long, int> > dfs(int node, long long sum) {
  priority_queue<pair<long long, int> > mine;
  for (int i = 0; i < adjList[node].size(); i++) {
    pair<long long, int> ch = adjList[node][i];
    priority_queue<pair<long long, int> > temp = dfs(ch.first, sum + ch.second);
    while (temp.size() && temp.top().first > sum) {
      temp.pop();
    }
    if (temp.size() > mine.size()) swap(temp, mine);
    while (temp.size()) {
      pair<long long, int> tempp = temp.top();
      temp.pop();
      mine.push(tempp);
    }
  }
  cnt[node] += mine.size();
  mine.push({sum - arr[node], node});
  return mine;
  for (int i = 0; i < adjList[node].size(); i++)
    dfs(adjList[node][i].first, sum + adjList[node][i].second);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  adjList.resize(n + 1);
  int parent, num;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &parent, &num);
    parent--;
    adjList[parent].push_back(make_pair(i + 1, num));
  }
  dfs(0, 0);
  for (int i = 0; i < n; i++) printf("%d ", cnt[i]);
  return 0;
}
