#include <bits/stdc++.h>
using namespace std;
void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
}
const int MAXN = 2e5 + 4;
const int LN = 21;
long long A[MAXN];
int par[MAXN];
int n;
vector<pair<int, long long>> g[MAXN];
vector<pair<long long, int>> d;
int BIT[MAXN];
void upd(int idx, int val) {
  while (idx < MAXN) {
    BIT[idx] += val;
    idx += (idx & -idx);
  }
}
void range_upd(int l, int r, int val = 1) {
  upd(l, val);
  upd(r + 1, -val);
}
int ask(int idx) {
  int ret = 0;
  while (idx) {
    ret += BIT[idx];
    idx -= (idx & -idx);
  }
  return ret;
}
int subsz[MAXN];
void walk(int u) {
  subsz[u] = 1;
  for (auto v : g[u]) {
    walk(v.first);
    subsz[u] += subsz[v.first];
  }
}
int chainno;
int chainidx[MAXN];
int pos[MAXN];
int chainhead[MAXN];
int ptr = 0;
void hld(int u) {
  if (chainhead[chainno] == 0) {
    chainhead[chainno] = u;
  }
  chainidx[u] = chainno;
  pos[u] = ++ptr;
  int heaviest = 0;
  for (auto it : g[u]) {
    if (!heaviest || subsz[heaviest] < subsz[it.first]) {
      heaviest = it.first;
    }
  }
  if (heaviest) {
    hld(heaviest);
  }
  for (auto it : g[u]) {
    if (it.first != heaviest) {
      chainno++;
      hld(it.first);
    }
  }
}
void update(int u, int v) {
  int uchain = chainidx[u];
  int vchain = chainidx[v];
  while (1) {
    uchain = chainidx[u];
    if (uchain == vchain) {
      range_upd(pos[v], pos[u]);
      return;
    }
    int head = chainhead[uchain];
    range_upd(pos[head], pos[u]);
    u = par[head];
  }
}
int find_vertex(long long val) {
  int l = 0;
  int r = d.size() - 1;
  int mid;
  int ret = r;
  long long ff = d[r].first;
  while (l <= r) {
    mid = (l + r) / 2;
    if ((ff - d[mid].first) <= val) {
      ret = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return d[ret].second;
}
void dfs(int u, long long wt) {
  d.push_back({wt, u});
  int v = find_vertex(A[u]);
  update(u, v);
  for (auto it : g[u]) {
    dfs(it.first, wt + it.second);
  }
  d.pop_back();
}
int main(int argc, char* argv[]) {
  io();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  int p;
  long long w;
  for (int i = 2; i <= n; i++) {
    cin >> p >> w;
    g[p].push_back({i, w});
    par[i] = p;
  }
  walk(1);
  hld(1);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    cout << (ask(pos[i]) - 1) << " ";
  }
  return 0;
}
