#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int H[N], to[N], len[N], nxt[N], e = 1;
void addedge(int t, int v, int s) {
  e++, to[e] = v, len[e] = s, nxt[e] = H[t], H[t] = e;
  e++, to[e] = t, len[e] = s, nxt[e] = H[v], H[v] = e;
}
long long val[N];
void init_(int u, int f) {
  for (int i = H[u], v = to[i]; i; i = nxt[i], v = to[i])
    if (v != f) {
      init_(v, u);
      val[u] = max(val[u], val[v] + len[i]);
    }
}
void Build(int u, int f, long long s) {
  val[u] = max(val[u], s);
  vector<long long> vec;
  vec.push_back(s);
  for (int i = H[u], v = to[i]; i; i = nxt[i], v = to[i])
    if (v != f) vec.push_back(val[v] + len[i]);
  sort(vec.begin(), vec.end(), greater<long long>());
  for (int i = H[u], v = to[i]; i; i = nxt[i], v = to[i])
    if (v != f) {
      if (val[v] + len[i] == vec[0])
        Build(v, u, vec[1] + len[i]);
      else
        Build(v, u, vec[0] + len[i]);
    }
}
int fa[N][21];
int pre[N], suf[N], tot;
void Init_(int u, int f) {
  fa[u][0] = f;
  for (int i = 1; i <= 20; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  pre[u] = ++tot;
  for (int i = H[u], v = to[i]; i; i = nxt[i], v = to[i])
    if (v != f) Init_(v, u);
  suf[u] = tot + 1;
}
int tree[N], n;
void modify(int k, int add) {
  if (!k) return;
  for (; k <= n; k += k & -k) tree[k] += add;
}
int query(int k) {
  int ans = 0;
  for (; k; k -= k & -k) ans += tree[k];
  return ans;
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int t, v, s;
    scanf("%d%d%d", &t, &v, &s);
    addedge(t, v, s);
  }
  init_(1, 0);
  Build(1, 0, 0);
  int u = 1;
  for (int i = 1; i <= n; i++)
    if (val[i] < val[u]) u = i;
  Init_(u, 0);
  int m;
  cin >> m;
  while (m--) {
    long long d;
    cin >> d;
    memset(tree, 0, sizeof(tree));
    for (int i = 1; i <= n; i++) {
      int j = i;
      for (int k = 20; k >= 0; k--)
        if (val[i] - val[fa[j][k]] <= d) j = fa[j][k];
      j = fa[j][0];
      modify(pre[i], 1);
      modify(pre[j], -1);
    }
    int res = 0;
    for (int i = 1; i <= n; i++) {
      int add = query(suf[i] - 1);
      int Dec = query(pre[i] - 1);
      res = max(res, add - Dec);
    }
    printf("%d\n", res);
  }
  return 0;
}
