#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= fh;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
long long n;
long long a[200005];
long long depth[200005], dist[200005], fa[200005][20];
vector<pair<long long, long long>> g[200005];
long long ans[200005];
inline void bfs() {
  memset(depth, 0x3f, sizeof(depth));
  memset(dist, 0x3f, sizeof(dist));
  depth[0] = 0, depth[1] = 1;
  dist[0] = dist[1] = 0;
  queue<long long> q;
  q.push(1);
  while (!q.empty()) {
    long long p = q.front();
    q.pop();
    for (register long long i = 0; i < g[p].size(); ++i)
      if (depth[g[p][i].first] > depth[p] + 1) {
        depth[g[p][i].first] = depth[p] + 1;
        dist[g[p][i].first] = dist[p] + g[p][i].second;
        q.push(g[p][i].first);
        fa[g[p][i].first][0] = p;
        for (register long long k = 1; k <= 19; ++k)
          fa[g[p][i].first][k] = fa[fa[g[p][i].first][k - 1]][k - 1];
      }
  }
}
inline bool check(long long x, long long dep) {
  long long tmp = x;
  for (register long long k = 19; k >= 0; --k)
    if (depth[fa[tmp][k]] >= dep) tmp = fa[tmp][k];
  return dist[x] - dist[tmp] <= a[x];
}
inline void get_ans(long long x) {
  for (register long long i = 0; i < g[x].size(); ++i) {
    get_ans(g[x][i].first);
    ans[x] += ans[g[x][i].first];
  }
}
signed main() {
  read(n);
  for (register long long i = 1; i <= n; ++i) read(a[i]);
  for (register long long i = 2; i <= n; ++i) {
    long long p, w;
    read(p);
    read(w);
    g[p].push_back(make_pair(i, w));
  }
  bfs();
  for (register long long i = 1; i <= n; ++i) {
    long long l = 1, r = depth[i];
    while (l < r) {
      long long mid = l + r >> 1;
      if (check(i, mid))
        r = mid;
      else
        l = mid + 1;
    }
    long long tmp = i;
    for (register long long k = 19; k >= 0; --k)
      if (depth[fa[tmp][k]] >= l) tmp = fa[tmp][k];
    ans[i]++;
    ans[fa[tmp][0]]--;
  }
  get_ans(1);
  for (register long long i = 1; i <= n; ++i) write(ans[i] - 1), putchar(' ');
  puts("");
  return 0;
}
