#include <bits/stdc++.h>
using namespace std;
template <class T>
class RangeTree {
 private:
  int N;
  vector<T> a;
  vector<int> L, R;

 public:
  RangeTree(vector<T> &dat) : a(dat) {
    int h = log2(dat.size() * 2 - 1);
    N = 1 << h;
    a.resize(N, numeric_limits<T>::min());
    L.resize(N * h);
    R.resize(N * h);
    vector<T> b(N);
    for (int i = h - 1; i >= 0; i--) {
      int s = N >> i, t = s / 2;
      for (int j = 0; j < N; j++) b[j] = a[j];
      for (int j = 0; j < N; j += s) {
        int l = j, r = l + t, ll = r, rr = r + t;
        for (int k = j; k < rr; k++) {
          L[N * i + k] = l;
          R[N * i + k] = r;
          a[k] = l < ll && (r == rr || b[l] < b[r]) ? b[l++] : b[r++];
        }
      }
    }
  }
  int countGE(int l, int r, T x) {
    function<int(int, int, int, int)> f = [&](int d, int ll, int rr, int x) {
      if (rr <= l || r <= ll || x >= rr) return 0;
      if (l <= ll && rr <= r) return rr - x;
      int mm = (ll + rr) / 2;
      return f(d + N, ll, mm, L[d + x]) + f(d + N, mm, rr, R[d + x]);
    };
    return f(0, 0, N, lower_bound(a.begin(), a.end(), x) - a.begin());
  }
};
struct edge {
  int v, w;
};
int main() {
  int n;
  cin >> n;
  vector<vector<edge>> g(n);
  vector<int64_t> a(n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 1; i < n; i++) {
    int p, w;
    scanf("%d %d", &p, &w);
    g[p - 1].push_back({i, w});
  }
  vector<int> ll(n), rr(n);
  int k = 0;
  vector<int64_t> d(n);
  function<void(int)> dfs = [&](int u) {
    ll[u] = k++;
    for (auto e : g[u]) d[e.v] = d[u] + e.w, dfs(e.v);
    rr[u] = k;
  };
  dfs(0);
  vector<int64_t> b(n);
  for (int i = 0; i < n; i++) b[ll[i]] = -(d[i] - a[i]);
  RangeTree<int64_t> tr(b);
  for (int i = 0; i < n; i++)
    printf("%d ", tr.countGE(ll[i] + 1, rr[i], -d[i]));
}
