#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long kkk = 0, x = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') c = getchar(), x = -1;
  while (c >= '0' && c <= '9')
    kkk = (kkk << 3) + (kkk << 1) + (c - '0'), c = getchar();
  return kkk * x;
}
long long n, q, head[100001], tot, dis[100001], Fa[100001], F[100001],
    id[100001], root, far;
long long father[100001], size[100001], ans[100001], cnt[100001];
struct sb {
  long long to, nextn, l;
} a[200001];
void ADD(long long from, long long to, long long l) {
  a[++tot].to = to, a[tot].nextn = head[from], a[tot].l = l;
  head[from] = tot;
}
void find(long long u, long long fa) {
  if (dis[u] > dis[far]) far = u;
  Fa[u] = fa;
  for (long long i = head[u]; i != 0; i = a[i].nextn) {
    long long v = a[i].to;
    if (v == fa) continue;
    dis[v] = dis[u] + a[i].l;
    find(v, u);
  }
}
long long cmp(long long x, long long y) {
  return F[x] > F[y] || (F[x] == F[y] && abs(x - root) > abs(y - root));
}
long long find(long long k) {
  if (father[k] != k) father[k] = find(father[k]);
  return father[k];
}
signed main() {
  n = read();
  for (long long i = 1; i < n; ++i) {
    long long u = read(), v = read(), l = read();
    ADD(u, v, l);
    ADD(v, u, l);
  }
  find(1, 0);
  dis[far] = 0;
  find(far, 0);
  for (long long i = 1; i <= n; ++i) F[i] = max(F[i], dis[i]);
  dis[far] = 0;
  find(far, 0);
  for (long long i = 1; i <= n; ++i) F[i] = max(F[i], dis[i]), id[i] = i;
  root = 1;
  for (long long i = 1; i <= n; ++i)
    if (F[i] < F[root]) root = i;
  find(root, 0);
  sort(id + 1, id + n + 1, cmp);
  q = read();
  while (q--) {
    long long lim = read(), ANS = 1, l = 1, out = 1;
    memset(cnt, 0, sizeof(cnt));
    for (long long i = 1; i <= n; ++i) father[i] = i, size[i] = 1, ans[i] = 1;
    cnt[1] = n;
    for (long long i = 1; i <= n; ++i) {
      for (long long j = head[id[i]]; j != 0; j = a[j].nextn) {
        long long v = a[j].to;
        if (v == Fa[id[i]]) continue;
        long long au = find(id[i]), av = find(v);
        if (size[au] > size[av]) swap(au, av);
        size[av] += size[au];
        father[au] = av;
        cnt[ans[av]]--;
        cnt[ans[au]]--;
        ans[av] += ans[au];
        if (ans[av] > ANS) ANS = ans[av];
        cnt[ans[av]]++;
      }
      while (F[id[l]] - F[id[i]] > lim) {
        long long au = find(id[l]);
        cnt[ans[au]]--;
        if (ans[au] == ANS && !cnt[ans[au]]) --ANS;
        ans[au]--;
        cnt[ans[au]]++;
        ++l;
      }
      out = max(out, ANS);
    }
    printf("%lld\n", out);
  }
  return 0;
}
