#include <bits/stdc++.h>
using namespace std;
int n, a[200010];
struct E {
  int a, b, w;
  E(int a, int b, int w) : a(a), b(b), w(w) {}
};
vector<E> g[200010];
vector<long long> depth;
vector<int> branch;
int ps[200010];
void dfs(int v, long long d) {
  branch.push_back(v);
  depth.push_back(d);
  for (E &e : g[v]) {
    dfs(e.b, d + e.w);
  }
  int l = 0, r = depth.size() - 1;
  while (l + 1 < r) {
    int m = l + (r - l) / 2;
    if (depth[m] + a[v] < depth.back()) {
      l = m;
    } else {
      r = m;
    }
  }
  int p = (depth[l] + a[v] >= depth.back() ? l : r);
  ps[v]++;
  if (p) {
    ps[branch[p - 1]]--;
  }
  branch.pop_back();
  depth.pop_back();
}
int ans[200010];
int dfs2(int v) {
  ans[v] = ps[v];
  for (E &e : g[v]) {
    ans[v] += dfs2(e.b);
  }
  return ans[v];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i < n; i++) {
    int p, w;
    scanf("%d%d", &p, &w);
    g[p - 1].push_back(E(p - 1, i, w));
  }
  dfs(0, 0);
  dfs2(0);
  for (int i = 0; i < n; i++) {
    printf("%d ", ans[i] - 1);
  }
}
