#include <bits/stdc++.h>
int mox[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int moy[8] = {0, 0, 1, -1, -1, -1, 1, 1};
char mover[4] = {'D', 'U', 'R', 'L'};
const long long INF = 1LL << 61;
const int inf = 2e9;
const long double PI = acos(-1);
bool debug;
using namespace std;
void solve();
int main() {
  debug = 0;
  cout.precision(30);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
const int N = 200005;
const int lg = 26;
long long a[N], b, s[N][lg], pr[N][lg];
int n, x, ans[N], h[N];
vector<pair<int, long long> > gr[N];
vector<pair<int, int> > dfs_list;
void dfs1(int v, int par = 0, long long c = 0) {
  s[v][0] = c;
  pr[v][0] = par;
  h[v] = h[par] + 1;
  for (int j = 1; j < lg; j++) {
    pr[v][j] = pr[pr[v][j - 1]][j - 1];
    s[v][j] = s[v][j - 1] + s[pr[v][j - 1]][j - 1];
  }
  for (int i = 0; i < (int)gr[v].size(); i++)
    dfs1(gr[v][i].first, v, gr[v][i].second);
}
long long get_s(int v, int h) {
  long long ss = 0;
  for (int i = lg; i >= 0; i--)
    if (h & (1 << i)) ss += s[v][i], v = pr[v][i];
  return ss;
}
void dfs(int v, long long last_cost = INF) {
  if (last_cost <= a[v]) {
    int l = 1, r = h[v];
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      long long tmp = get_s(v, mid);
      if (tmp <= a[v])
        l = mid;
      else
        r = mid;
    }
    dfs_list[(int)dfs_list.size() - 1].second++;
    dfs_list[(int)dfs_list.size() - 1 - l].second--;
  }
  dfs_list.push_back({v, 0});
  for (int i = 0; i < (int)gr[v].size(); i++)
    dfs(gr[v][i].first, gr[v][i].second);
  int i = (int)dfs_list.size() - 1;
  dfs_list[i - 1].second += dfs_list[i].second;
  ans[v] += dfs_list[i].second;
  dfs_list.pop_back();
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 2; i <= n; i++) {
    scanf("%d %I64d", &x, &b);
    gr[x].push_back({i, b});
  }
  dfs1(1);
  dfs_list.push_back({0, 0});
  dfs(1);
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
