#include <bits/stdc++.h>
using namespace std;
const int SO = 2e5 + 5;
int n, g[SO], u, v, p;
long long a[SO], gt;
struct so {
  int v;
  long long gt;
};
vector<so> ke[SO], d;
long long it[SO * 4], lazy[SO * 4], kq[SO];
void update(int node, int l, int r) {
  if ((l > r) || (l > v) || (r < u)) return;
  if ((l >= u) && (r <= v)) {
    it[node] += gt;
    lazy[node] += gt;
  } else {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
    it[node * 2] += lazy[node];
    it[node * 2 + 1] += lazy[node];
    lazy[node] = 0;
    update(node * 2, l, (l + r) / 2);
    update(node * 2 + 1, (l + r) / 2 + 1, r);
    it[node] = it[node * 2] + it[node * 2 + 1];
  }
  return;
}
long long query(int node, int l, int r) {
  if ((l > r) || (l > p) || (r < p)) return 0;
  if (l == r)
    return it[node];
  else {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
    it[node * 2] += lazy[node];
    it[node * 2 + 1] += lazy[node];
    lazy[node] = 0;
    return (query(node * 2, l, (l + r) / 2) +
            query(node * 2 + 1, (l + r) / 2 + 1, r));
  }
}
bool cmp(so a, so b) { return (a.gt < b.gt); }
void solve(int diem) {
  so b = {0, d.back().gt - a[diem]};
  int t = std::lower_bound(d.begin(), d.end(), b, cmp) - d.begin();
  u = t + 1, v = d.size() - 1;
  gt = 1;
  update(1, 1, n);
  for (int i = 0; i < ke[diem].size(); i++) {
    int v = ke[diem][i].v;
    long long gg = ke[diem][i].gt + d.back().gt;
    d.push_back({diem, gg});
    solve(v);
  }
  p = d.size();
  kq[diem] = query(1, 1, n);
  u = p, v = p;
  gt = -kq[diem];
  update(1, 1, n);
  d.pop_back();
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 2; i <= n; i++) {
    int x;
    long long gt;
    scanf("%d%I64d", &x, &gt);
    ke[x].push_back({i, gt});
  }
  d.push_back({1, 0});
  solve(1);
  for (int i = 1; i <= n; i++) printf("%I64d ", kq[i]);
  return 0;
}
