#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 2e5 + 5;
vector<int> g[N];
int n, ans[N], anc[N], val[N], a[N];
long long d[N];
int dfs(int x, int dep) {
  anc[dep] = x;
  ans[x] = 1;
  int l = 1, r = dep - 1, cur = dep;
  while (l <= r) {
    int mid = l + r >> 1;
    if (d[x] - d[anc[mid]] <= a[x])
      cur = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  ans[anc[cur - 1]]--;
  for (int y : g[x]) {
    d[y] = d[x] + val[y];
    ans[x] += dfs(y, dep + 1);
  }
  return ans[x];
}
signed main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  for (int i = 2, fa; i <= n; i++) {
    read(fa);
    read(val[i]);
    g[fa].push_back(i);
  }
  dfs(1, 1);
  for (int i = 1; i <= n; i++) write(ans[i] - 1), putchar(' ');
}
