#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
template <class T>
inline bool scan(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
using namespace std;
int n;
struct node {
  int v, next, w;
} edge[200005 << 1];
int head[200005], cnt;
void add_edge(int u, int v, int w) {
  node &e = edge[cnt];
  e.v = v, e.w = w, e.next = head[u], head[u] = cnt++;
}
int a[200005], num[200005], ans[200005];
int fa[200005][22], deep[200005];
long long len[200005];
int DEG;
bool vis[200005];
void bfs(int root) {
  DEG = 20;
  queue<int> q;
  while (!q.empty()) q.pop();
  deep[root] = 0;
  len[root] = 0;
  fa[root][0] = root;
  q.push(root);
  memset(vis, 0, sizeof vis);
  vis[root] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 1; i < DEG; i++) {
      fa[u][i] = fa[fa[u][i - 1]][i - 1];
    }
    for (int i = head[u]; i != -1; i = edge[i].next) {
      int v = edge[i].v;
      if (vis[v]) continue;
      deep[v] = deep[u] + 1;
      fa[v][0] = u;
      len[v] = len[u] + edge[i].w;
      q.push(v);
      vis[v] = 1;
    }
  }
}
void dfs(int u, int father) {
  ans[u] = num[u];
  for (int i = head[u]; i + 1; i = edge[i].next) {
    int v = edge[i].v;
    if (v == father) continue;
    dfs(v, u);
    ans[u] += ans[v];
  }
}
int solve(int u, long long d) {
  int ans = 0;
  if (len[u] <= d) {
    return 0;
  }
  int i = 0;
  for (; i < 20; i++) {
    if (deep[u] - (1 << (i + 1)) >= 0 && len[u] - len[fa[u][(i + 1)]] <= d)
      continue;
    else
      break;
  }
  if (len[u] - len[fa[u][i]] > d) return fa[u][i];
  return solve(fa[u][i], d - (len[u] - len[fa[u][i]]));
}
int main() {
  memset(head, -1, sizeof(head));
  scan(n);
  for (int i = 1; i <= n; i++) {
    scan(a[i]);
  }
  for (int u = 2; u <= n; u++) {
    int v, w;
    scan(v), scan(w);
    add_edge(u, v, w);
    add_edge(v, u, w);
  }
  bfs(1);
  memset(num, 0, sizeof(num));
  for (int i = 2; i <= n; i++) {
    num[fa[i][0]]++;
    int p = solve(i, a[i]);
    num[p]--;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
