#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200005;
long long A[MAX_N];
vector<int> G[MAX_N];
pair<int, long long> UP[MAX_N][20];
int n, start[MAX_N], finish[MAX_N], W[MAX_N];
bool vis[MAX_N];
void jump(int v) {
  int p = 0;
  int cur = v;
  if (v == 1 || UP[v][0].second > A[v]) return;
  while (UP[v][p + 1].second <= A[v] && UP[v][p + 1].first != 0) p++;
  while (p >= 0) {
    if (UP[cur][p].first != 0 && UP[cur][p].second <= A[v]) {
      A[v] -= UP[cur][p].second;
      cur = UP[cur][p].first;
    } else
      p--;
  }
  start[UP[v][0].first]++;
  finish[cur]++;
}
void dfs(int k) {
  vis[k] = true;
  W[k] = start[k];
  for (vector<int>::iterator it = G[k].begin(); it != G[k].end(); it++)
    if (!vis[*it]) {
      dfs(*it);
      W[k] += start[*it];
      start[k] += start[*it];
    }
  start[k] -= finish[k];
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 2; i <= n; i++) {
    int p;
    long long w;
    cin >> p >> w;
    G[i].push_back(p);
    G[p].push_back(i);
    UP[i][0] = make_pair(p, w);
  }
  for (int p = 1; p < 20; p++)
    for (int i = 1; i <= n; i++) {
      int prev = UP[i][p - 1].first;
      int v = UP[prev][p - 1].first;
      long long w = UP[prev][p - 1].second + UP[i][p - 1].second;
      UP[i][p] = make_pair(v, w);
    }
  for (int i = 1; i <= n; i++) jump(i);
  dfs(1);
  for (int i = 1; i <= n; i++) cout << W[i] << " ";
  return 0;
}
