#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
vector<pair<int, int> > G[N];
int A[N];
int idx;
int st[N];
int ed[N];
long long dis[N];
void dfs(int u, long long d) {
  dis[u] = d;
  st[u] = ++idx;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i].first;
    int w = G[u][i].second;
    dfs(v, d + w);
  }
  ed[u] = idx;
}
struct BIT {
  const static int N = 1e6;
  int F[N];
  void init() { memset(F, 0, sizeof(F)); }
  void update(int x, int val) {
    while (x < N) {
      F[x] += val;
      x += x & -x;
    }
  }
  int query(int x) {
    int res = 0;
    while (x > 0) {
      res += F[x];
      x -= x & -x;
    }
    return res;
  }
} tree;
struct Node {
  int t, id;
  long long v;
  Node() {}
  Node(int _t, int _id, long long _v) : t(_t), id(_id), v(_v) {}
  bool operator<(const Node &rhs) const {
    if (v == rhs.v) return t < rhs.t;
    return v < rhs.v;
  }
};
vector<Node> B;
int ans[N];
int main() {
  int n;
  int p, w;
  cin >> n;
  idx = 0;
  tree.init();
  for (int i = 1; i <= n; i++) cin >> A[i];
  for (int i = 2; i <= n; i++) {
    cin >> p >> w;
    G[p].push_back(make_pair(i, w));
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    B.push_back(Node(1, i, dis[i] - A[i]));
    B.push_back(Node(2, i, dis[i]));
  }
  sort(B.begin(), B.end());
  for (auto &it : B) {
    if (it.t == 1)
      tree.update(st[it.id], 1);
    else
      ans[it.id] = tree.query(ed[it.id]) - tree.query(st[it.id] - 1);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] - 1 << " ";
  return 0;
}
