#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int INF = 2e9;
vector<pair<int, long long> > g[MAXN];
long long val[MAXN], ans[MAXN];
multiset<long long> *merge(multiset<long long> *a, multiset<long long> *b) {
  if (a == NULL) return b;
  if (b == NULL) return a;
  if (a->size() > b->size()) {
    for (multiset<long long>::iterator it = b->begin(); it != b->end(); it++)
      a->insert(*it);
    delete b;
    return a;
  }
  for (multiset<long long>::iterator it = a->begin(); it != a->end(); it++)
    b->insert(*it);
  delete a;
  return b;
}
multiset<long long> *dfs(int u, long long s) {
  multiset<long long> *ret = NULL;
  if (g[u].empty()) {
    ret = new multiset<long long>();
    ret->insert(-(s - val[u]));
    ans[u] = 0;
    return ret;
  }
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first, w = g[u][i].second;
    ret = merge(ret, dfs(v, s + w));
  }
  while (!ret->empty() && -*ret->begin() > s) ret->erase(ret->begin());
  ans[u] = ret->size();
  ret->insert(-(s - val[u]));
  return ret;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> val[i];
  for (int i = 1; i < n; i++) {
    int p;
    long long w;
    cin >> p >> w;
    g[--p].push_back(make_pair(i, w));
  }
  delete dfs(0, 0);
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}
