func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n;   int head[N], Next[N << 1], ver[N << 1], size[N], edge[N << 1], w[N];   int tot;   long long ans;   void add(int x, int y, int z) {     ver[++tot] = y;     edge[tot] = z;     Next[tot] = head[x];     head[x] = tot;   }   void dfs(int x, int fa) {     size[x] = 1;     for (int i = head[x]; i; i = Next[i]) {       int y = ver[i];       if (y == fa) continue;       dfs(y, x);       size[x] += size[y];     }   }   void solve(int x, int fa, long long s) {     for (int i = head[x]; i; i = Next[i]) {       int y = ver[i], z = edge[i];       if (y == fa) continue;       if (s + (long long)z > (long long)w[y])         ans += (long long)size[y];       else         solve(y, x, max(0ll, s + (long long)z));     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &w[i]);     for (int i = 2; i <= n; i++) {       int p, c;       scanf( %d%d , &p, &c);       add(p, i, c);       add(i, p, c);     }     dfs(1, 0);     solve(1, 0, 0ll);     printf( %lld n , ans);     return 0;   }   