#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T, typename second>
T expo(T b, second e, const T &m) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b) % m, e >> 1, m)
                      : (b * expo((b * b) % m, e >> 1, m)) % m;
}
template <typename T, typename second>
T expo(T b, second e) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b), e >> 1) : (b * expo((b * b), e >> 1));
}
template <typename T, typename second>
T modinv(T a, second mod) {
  return expo(a, mod - 2, mod);
}
template <class T, class second>
std::ostream &operator<<(std::ostream &os, const std::pair<T, second> &t) {
  os << "(" << t.first << ", " << t.second << ")";
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &t) {
  os << "[";
  for (__typeof(t.begin()) it = t.begin(); it != t.end(); it++) {
    if (it != t.begin()) os << ", ";
    os << *it;
  }
  os << "]";
  return os;
}
template <typename T>
void in(T &x) {
  T c = getchar();
  while (((c < 48) || (c > 57)) && (c != '-')) c = getchar();
  bool neg = false;
  if (c == '-') neg = true;
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x * 10) + (c - 48);
  if (neg) x = -x;
}
const int MAXN = 2e5 + 3;
long long arr[MAXN], n;
vector<int> adj[MAXN];
vector<long long> wt[MAXN];
int ans[MAXN];
int partial[MAXN];
int pa[MAXN];
void make_p(int r, int p, long long sofar, vector<pair<long long, int> > &v) {
  v.push_back({sofar, r});
  pair<long long, int> temp = {sofar - arr[r], 0};
  auto it = lower_bound(v.begin(), v.end(), temp);
  partial[r] += 1;
  partial[pa[it->second]] -= 1;
  for (int i = 0; i < adj[r].size(); i++) {
    if (adj[r][i] != p) {
      make_p(adj[r][i], r, sofar + wt[r][i], v);
    }
  }
  v.pop_back();
}
void go(int r, int p) {
  for (auto &elem : adj[r]) {
    if (elem != p) {
      go(elem, r);
      partial[r] += partial[elem];
    }
  }
}
int main() {
  int a, b;
  in(n);
  for (int i = 1; i <= n; i++) {
    in(arr[i]);
  }
  for (int i = 2; i <= n; i++) {
    in(a), in(b);
    adj[i].push_back(a);
    pa[i] = a;
    adj[a].push_back(i);
    wt[i].push_back(b);
    wt[a].push_back(b);
  }
  vector<pair<long long, int> > v;
  make_p(1, 0, 0, v);
  go(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d ", partial[i] - 1);
  }
  puts("");
  return 0;
}
