#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math")
#pragma GCC target("avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long Linf = 0x7f7f7f7f7f7f7f7f;
const int Inf = 0x3f3f3f3f;
const int MAXN = 2e5 + 10;
int n, a[MAXN], dep[MAXN], f[MAXN][22];
long long dis[MAXN];
vector<vector<pair<int, int>>> g(MAXN);
void dfsInit(int x, int pre, int d) {
  dep[x] = d;
  f[x][0] = pre;
  for (auto pi : g[x]) {
    int v = pi.first, w = pi.second;
    dis[v] = dis[x] + w;
    dfsInit(v, x, d + 1);
  }
}
void init(int x, int pre, int d) {
  dfsInit(x, pre, d);
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
}
int getLCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int getKfa(int x, int k) {
  for (int i = 20; i >= 0; i--)
    if ((k >> i) & 1) x = f[x][i];
  return x;
}
long long getDis(int x, int y) {
  return dis[x] + dis[y] - 2 * dis[getLCA(x, y)];
}
int siz[MAXN], son[MAXN], bj[MAXN];
void dfsSon(int x) {
  siz[x] = 1;
  son[x] = -1;
  for (auto pi : g[x]) {
    int v = pi.first;
    dfsSon(v);
    siz[x] += siz[v];
    if (son[x] == -1 || (siz[son[x]] < siz[v])) son[x] = v;
  }
}
void dfsBj(int x) {
  for (auto pi : g[x]) {
    int v = pi.first;
    dfsBj(v);
  }
  int l = 0, r = dep[x], pos = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (getDis(getKfa(x, mid), x) <= a[x])
      l = mid + 1, pos = mid;
    else
      r = mid - 1;
  }
  bj[x] = dep[x] - pos;
}
int myson;
struct BIT {
  int sum[MAXN];
  int lowbit(int x) { return x & -x; }
  int getSum(int x) {
    int res = 0;
    while (x) res += sum[x], x -= lowbit(x);
    return res;
  }
  void add(int x, int C) {
    while (x <= n) sum[x] += C, x += lowbit(x);
  }
} t;
int ans[MAXN];
void calOth(int x, int top) {
  if (x != top) t.add(bj[x] + 1, 1);
  for (auto pi : g[x]) {
    int v = pi.first;
    if (v == myson) continue;
    calOth(v, top);
  }
}
void clear(int x) {
  t.add(bj[x] + 1, -1);
  for (auto pi : g[x]) {
    int v = pi.first;
    clear(v);
  }
}
void dfs(int x, int fl) {
  for (auto pi : g[x]) {
    int v = pi.first;
    if (v == son[x]) continue;
    dfs(v, 0);
  }
  if (son[x] != -1) dfs(son[x], 1), myson = son[x];
  calOth(x, x);
  ans[x] = t.getSum(dep[x] + 1);
  t.add(bj[x] + 1, 1);
  if (!fl) clear(x);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    int pre, w;
    cin >> pre >> w;
    g[pre].push_back(make_pair(i, w));
  }
  init(1, 0, 0);
  dfsSon(1);
  dfsBj(1);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
