#include <bits/stdc++.h>
using namespace std;
const int64_t N = 2e5 + 9, logn = 20;
map<pair<int64_t, int64_t>, int64_t> w;
int64_t n, a[N], d[N][logn], anc[N][logn], x, y, ps[N], answer[N];
vector<int64_t> adj[N];
void dfs(int64_t node, int64_t par = 0) {
  anc[node][0] = par;
  d[node][0] = w[make_pair(node, par)];
  for (int64_t i = 1; i < logn; i++)
    anc[node][i] = anc[anc[node][i - 1]][i - 1];
  for (int64_t i = 1; i < logn; i++)
    d[node][i] = d[anc[node][i - 1]][i - 1] + d[node][i - 1];
  for (int64_t i : adj[node])
    if (i != par) dfs(i, node);
}
int64_t dfs2(int64_t node, int64_t par = 0) {
  answer[node] = ps[node];
  for (int64_t i : adj[node])
    if (i != par) answer[node] += dfs2(i, node);
  return answer[node];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int64_t i = 1; i <= n; i++) cin >> a[i];
  for (int64_t i = 1; i < n; i++) {
    cin >> x >> y;
    adj[i + 1].push_back(x);
    adj[x].push_back(i + 1);
    w[make_pair(x, i + 1)] = y;
    w[make_pair(i + 1, x)] = y;
  }
  dfs(1, 0);
  for (int64_t i = 1; i <= n; i++) {
    int64_t cnt = 0, cur = i, distill = 0;
    for (int64_t j = logn - 1; j >= 0; j--) {
      if (distill + d[cur][j] <= a[i]) distill += d[cur][j], cur = anc[cur][j];
    }
    ps[anc[cur][0]]--;
    ps[anc[i][0]]++;
  }
  dfs2(1, 0);
  for (int64_t i = 1; i <= n; i++) cout << answer[i] << ' ';
  cout << endl;
}
