#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
vector<pair<long long, long long> > g[N];
long long dist[N * 2], i, j, k, x, y, z, n, m, a[N], tin[N], tout[N], t, sz,
    b[N];
vector<long long> tree[N * 4];
void dfs(long long x, long long pr, long long d) {
  sz++;
  b[sz] = x;
  t++;
  tin[x] = t;
  dist[x] = d;
  long long i;
  for (i = 0; i < g[x].size(); ++i) {
    if (g[x][i].first != pr) dfs(g[x][i].first, x, d + g[x][i].second);
  }
  tout[x] = t;
}
inline void build(long long v) {
  tree[v].reserve(tree[v * 2].size() + tree[v * 2 + 1].size());
  tree[v].resize(tree[v * 2].size() + tree[v * 2 + 1].size());
  merge(tree[v * 2].begin(), tree[v * 2].end(), tree[v * 2 + 1].begin(),
        tree[v * 2 + 1].end(), tree[v].begin());
}
long long get(long long v, long long l, long long r, long long le, long long rr,
              long long x) {
  long long mid;
  if (l > r || l > rr || r < le) return 0;
  if (l >= le && r <= rr) {
    long long a, b;
    a = 1;
    b = tree[v].size();
    while (b - a > 1) {
      mid = (a + b) >> 1;
      if (tree[v][mid - 1] <= x)
        a = mid;
      else
        b = mid;
    }
    if (tree[v][b - 1] <= x)
      return b;
    else if (tree[v][a - 1] <= x)
      return a;
    else
      return 0;
  }
  mid = (l + r) / 2;
  return get(v * 2, l, mid, le, rr, x) + get(v * 2 + 1, mid + 1, r, le, rr, x);
}
int main() {
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (i = 2; i <= n; ++i) {
    cin >> x >> y;
    g[x].push_back(make_pair(i, y));
    g[i].push_back(make_pair(x, y));
  }
  t = 0;
  sz = 0;
  dfs(1, -1, 0);
  sz = 1;
  while (sz < n) sz *= 2;
  for (i = 1; i <= n; ++i) {
    tree[sz + tin[i] - 1].push_back(dist[i] - a[i]);
  }
  for (i = sz - 1; i >= 1; --i) {
    build(i);
  }
  long long ans = 0;
  for (i = 1; i <= n; ++i) {
    ans = 0;
    x = i;
    ans = get(1, sz, sz + sz - 1, sz + tin[x], sz + tout[x] - 1, dist[x]);
    cout << ans << " ";
  }
}
