#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline long long read() {
  bool f = false;
  char ch = getchar();
  long long res = 0;
  while (ch < '0' || '9' < ch) f |= (ch == '-'), ch = getchar();
  while ('0' <= ch && ch <= '9') res = 10 * res + ch - '0', ch = getchar();
  return f ? -res : res;
}
const int N = 2e5 + 10;
int head[N], ver[N * 2], edge[N * 2], Next[N * 2], tot;
void add(int x, int y, int z) {
  ver[++tot] = y, edge[tot] = z, Next[tot] = head[x], head[x] = tot;
}
long long a[N];
long long dis[N];
bool vis[N];
int fa[N];
int ans[N];
void getdis(int u, int fa) {
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i], w = edge[i];
    if (v == fa) continue;
    dis[v] = dis[u] + w;
    getdis(v, u);
  }
}
struct node {
  long long dis, x;
  node(long long _dis = 0, long long _x = 0) { dis = _dis, x = _x; }
  bool operator<(const node& b) const { return dis < b.dis; }
};
vector<node> path;
void solve(int u) {
  path.push_back(node(dis[u], u));
  vis[u] = 1;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (vis[v]) continue;
    long long temp = dis[v] - a[v];
    auto pos = lower_bound(path.begin(), path.end(), temp);
    if (pos != path.end()) {
      ans[u]++;
      ans[fa[pos->x]]--;
    }
    solve(v);
    ans[u] += ans[v];
  }
  path.pop_back();
}
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  for (int i = 2; i <= n; i++) {
    int x = read(), y = read();
    fa[i] = x;
    add(i, x, y);
    add(x, i, y);
  }
  getdis(1, -1);
  solve(1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  puts("");
  return 0;
}
