#include <bits/stdc++.h>
using namespace std;
long long n;
long long p[200042][42];
vector<long long> ch[200042];
long long a[200042];
long long w[200042][42];
long long lvl[200042];
long long up[200042];
long long ctrl[200042];
void cntlvl(int v) {
  lvl[v] = lvl[p[v][0]] + 1;
  for (int w : ch[v]) cntlvl(w);
}
long long cntup(int v) {
  int vorg = v;
  long long dist = 0LL;
  int j = 41;
  while (j >= 0) {
    if (p[v][j] == 0 || dist + w[v][j] > a[vorg]) {
      j--;
      continue;
    }
    dist += w[v][j];
    v = p[v][j];
  }
  return lvl[v];
}
pair<map<long long, long long>, long long> cntctrl(int v) {
  if (ch[v].empty()) {
    ctrl[v] = 0LL;
    return (
        (up[v] < lvl[v])
            ? make_pair<map<long long, long long>, long long>({{up[v], 1}}, 1LL)
            : make_pair<map<long long, long long>, long long>({}, 0LL));
  }
  auto res = cntctrl(ch[v][0]);
  for (int i = 1; i < ch[v].size(); i++) {
    auto res2 = cntctrl(ch[v][i]);
    res.second += res2.second;
    for (auto el : res2.first) {
      res.first[el.first] += el.second;
    }
  }
  ctrl[v] = res.second;
  res.first[up[v]]++;
  res.second++;
  res.second -= res.first[lvl[v]];
  res.first.erase(lvl[v]);
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= n; i++) {
    cin >> p[i][0];
    cin >> w[i][0];
    ch[p[i][0]].push_back(i);
  }
  for (int j = 1; j < 42; j++) {
    for (int i = 2; i <= n; i++) {
      p[i][j] = p[p[i][j - 1]][j - 1];
      w[i][j] = w[i][j - 1] + w[p[i][j - 1]][j - 1];
    }
  }
  lvl[0] = 0;
  cntlvl(1);
  for (int i = 2; i <= n; i++) up[i] = cntup(i);
  cntctrl(1);
  for (int i = 1; i <= n; i++) cout << ctrl[i] << " ";
  return 0;
}
