#include <bits/stdc++.h>
using namespace std;
struct FastReader {
  FastReader &operator,(int &x) {
    scanf("%d", &x);
    return *this;
  }
  FastReader &operator,(signed long long &x) {
    scanf(
        "%"
        "ll"
        "d",
        &x);
    return *this;
  }
  FastReader &operator,(double &x) {
    scanf("%lf", &x);
    return *this;
  }
  FastReader &operator,(long double &x) {
    scanf("%Lf", &x);
    return *this;
  }
  FastReader &operator,(char &x) {
    do x = getchar();
    while (x == ' ' || x == '\n');
    return *this;
  }
  FastReader &operator,(char *x) {
    scanf("%s", x);
    return *this;
  }
  FastReader &operator,(string &x) {
    cin >> x;
    return *this;
  }
} in;
struct FastWriter {
  FastWriter &operator,(const int x) {
    printf("%d", x);
    return *this;
  }
  FastWriter &operator,(const signed long long x) {
    printf(
        "%"
        "ll"
        "d",
        x);
    return *this;
  }
  FastWriter &operator,(const double x) {
    printf(
        "%."
        "8"
        "lf",
        x);
    return *this;
  }
  FastWriter &operator,(const long double x) {
    printf(
        "%."
        "12"
        "Lf",
        x);
    return *this;
  }
  FastWriter &operator,(const char x) {
    putchar(x);
    return *this;
  }
  FastWriter &operator,(const char *x) {
    printf("%s", x);
    return *this;
  }
  FastWriter &operator,(const string &x) { return operator,(x.c_str()); }
} out;
template <class T>
inline T sqr(T x) {
  return x * x;
}
static const int N = 2e5 + 1111;
int n;
int val[N];
vector<pair<int, int> > g[N];
signed long long ans[N];
multiset<signed long long> *merge(multiset<signed long long> *a,
                                  multiset<signed long long> *b) {
  if (a == NULL) return b;
  if (b == NULL) return a;
  if (a->size() > b->size()) {
    for (multiset<signed long long>::iterator it = b->begin(); it != b->end();
         it++)
      a->insert(*it);
    delete b;
    return a;
  }
  for (multiset<signed long long>::iterator it = a->begin(); it != a->end();
       it++)
    b->insert(*it);
  delete a;
  return b;
}
multiset<signed long long> *dfs(int a, signed long long s = 0) {
  multiset<signed long long> *ret = NULL;
  if (g[a].empty()) {
    ret = new multiset<signed long long>();
    ret->insert(-(s - val[a]));
    ans[a] = 0;
    return ret;
  }
  for (size_t i = 0; i < g[a].size(); i++) {
    int b = g[a][i].first, w = g[a][i].second;
    ret = merge(ret, dfs(b, s + w));
  }
  while (!ret->empty() && -*ret->begin() > s) ret->erase(ret->begin());
  ans[a] = ret->size();
  ret->insert(-(s - val[a]));
  return ret;
}
int main() {
  in, n;
  for (int i = 0; i < n; i++) in, val[i];
  for (int i = 1; i < n; i++) {
    int x, y;
    in, x, y;
    x--;
    g[x].push_back(make_pair(i, y));
  }
  delete dfs(0);
  for (int i = 0; i < n; i++) out, ans[i], ' ';
  return 0;
}
