#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
template <class T>
int getbit(T x, int pos) {
  return (x >> (pos - 1)) & 1;
}
template <class T>
void turn_on(T &x, int pos) {
  x = x | ((T)1 << (pos - 1));
}
template <class T>
void turn_off(T &x, int pos) {
  x = x & ~((T)1 << (pos - 1));
}
template <class T>
T sqr(T a) {
  return a * a;
}
int len(string a) { return (int)a.length(); }
int n, bound[2 * 100002], t, bit[2 * 100002], G[2 * 100002], res[2 * 100002],
    pos[2 * 100002];
pair<long long, int> tmp1[2 * 100002], tmp2[2 * 100002], parent[2 * 100002];
long long l[2 * 100002], d[2 * 100002];
vector<int> a[2 * 100002];
long long level(int u) {
  return l[u] > -1 ? l[u] : l[u] = level(parent[u].second) + parent[u].first;
}
void update(int id) {
  if (id == 0) return;
  while (id <= n) {
    bit[id]++;
    id += id & (-id);
  }
}
int get(int id) {
  int res = 0;
  while (id > 0) {
    res += bit[id];
    id -= id & (-id);
  }
  return res;
}
void visit(int u) {
  ++t;
  bound[u] = t;
  G[t] = u;
  pos[u] = t;
  tmp1[t] = pair<long long, int>(l[u], t);
  tmp2[t] = pair<long long, int>(l[u] - d[u], t);
  for (auto v : a[u]) {
    visit(v);
    bound[u] = max(bound[u], bound[v]);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> d[i];
  for (int i = 1; i <= n - 1; ++i) {
    cin >> parent[i + 1].second >> parent[i + 1].first;
    a[parent[i + 1].second].push_back(i + 1);
  }
  memset(l, -1, sizeof(l));
  l[1] = 0;
  for (int i = 1; i <= n; ++i) level(i);
  visit(1);
  sort(tmp1 + 1, tmp1 + n + 1);
  sort(tmp2 + 1, tmp2 + n + 1);
  int head = 0;
  for (int i = 1; i <= n; ++i) {
    while (head < n && tmp1[i].first >= tmp2[head + 1].first) {
      ++head;
      update(tmp2[head].second);
    }
    res[G[tmp1[i].second]] =
        get(bound[G[tmp1[i].second]]) - get(tmp1[i].second);
  }
  for (int i = 1; i <= n; ++i) cout << res[i] << ' ';
}
