#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 100, M = 2e3 + 9, INF = 1e14 + 7, INF64 = 1e16 + 7;
const long double EPS = 1e-10;
long long l[N], r[N], ans[N], w[N], dp[N];
pair<long long, long long> b[N];
vector<vector<pair<int, int> > > a(N);
void dfs(int v, int p, int len) {
  int left, right, mid;
  left = -1;
  right = len - 1;
  while (right - left > 1) {
    mid = (left + right) / 2;
    if (b[len - 1].second - b[mid].second <= w[v])
      right = mid;
    else
      left = mid;
  }
  if (right < len - 1) {
    l[b[right].first]++;
    r[b[len - 2].first]++;
  }
  for (int i = 0; i < int(int((a[v]).size())); i++)
    if (a[v][i].first != p) {
      b[len] = make_pair(a[v][i].first, b[len - 1].second + a[v][i].second);
      dfs(a[v][i].first, v, len + 1);
    }
}
void dfs2(int v, int cur, int p = -1) {
  long long s = 0;
  cur += l[v];
  ans[v] = cur;
  cur -= r[v];
  for (int i = 0; i < int(int((a[v]).size())); i++)
    if (a[v][i].first != p) s += dp[a[v][i].first];
  for (int i = 0; i < int(int((a[v]).size())); i++)
    if (a[v][i].first != p)
      dfs2(a[v][i].first, cur - (s - dp[a[v][i].first]), v);
}
void dfs3(int v, int p = -1) {
  dp[v] += r[v] - l[v];
  for (int i = 0; i < int(int((a[v]).size())); i++)
    if (a[v][i].first != p) {
      dfs3(a[v][i].first, v);
      dp[v] += dp[a[v][i].first];
    }
}
int main() {
  int n, first, second;
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < int(n); i++) cin >> w[i];
  for (int i = 0; i < int(n - 1); i++) {
    cin >> first >> second;
    first--;
    a[first].push_back({i + 1, second});
    a[i + 1].push_back({first, second});
  }
  b[0] = make_pair(0, 0);
  for (int i = 0; i < int(int((a[0]).size())); i++) {
    b[1] = make_pair(a[0][i].first, a[0][i].second);
    dfs(a[0][i].first, 0, 2);
  }
  dfs3(0);
  dfs2(0, 0);
  for (int i = 0; i < int(n); i++) cout << ans[i] << ' ';
  return 0;
}
