#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const long long N = 200010;
inline long long read() {
  long long s = 0, w = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
long long n, Q, d[N], md[N], smd[N], F[N], root, id[N], nowid, siz[N], g[N];
long long head[N], maxE;
struct Edge {
  long long nxt, to, rdis;
} e[N << 1];
inline void Add(long long u, long long v, long long w) {
  e[++maxE].nxt = head[u];
  head[u] = maxE;
  e[maxE].to = v;
  e[maxE].rdis = w;
}
void DFS1(long long x, long long fa) {
  long long sz = 0;
  for (register long long i = head[x]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (v == fa) continue;
    d[v] = d[x] + e[i].rdis;
    DFS1(v, x);
    if (md[v] >= md[x])
      smd[x] = md[x], md[x] = md[v];
    else if (md[v] >= smd[x])
      smd[x] = md[v];
    sz++;
  }
  if (!sz) md[x] = d[x];
}
void DFS2(long long x, long long fa, long long w) {
  F[x] = max(md[x] - d[x], w);
  for (register long long i = head[x]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (v == fa) continue;
    long long nxt = w;
    if (md[v] - d[v] + e[i].rdis == md[x] - d[x])
      nxt = max(nxt, smd[x] - d[x]);
    else
      nxt = max(nxt, md[x] - d[x]);
    DFS2(v, x, nxt + e[i].rdis);
  }
}
void DFS3(long long x, long long fa) {
  siz[x] = 1;
  id[x] = ++nowid;
  for (register long long i = head[x]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (v == fa) continue;
    DFS3(v, x);
    siz[x] += siz[v];
  }
}
inline bool cp(long long x, long long y) {
  return F[x] == F[y] ? id[x] < id[y] : F[x] < F[y];
}
struct BIT {
  long long c[N];
  inline long long lowbit(long long x) { return x & (-x); }
  inline void Add(long long x, long long p) {
    for (; x <= n; x += lowbit(x)) c[x] += p;
  }
  inline long long Ask(long long x) {
    long long tt = 0;
    for (; x; x -= lowbit(x)) tt += c[x];
    return tt;
  }
} A;
signed main() {
  n = read();
  for (register long long i = 1; i < n; i++) {
    long long u, v, w;
    u = read(), v = read(), w = read();
    Add(u, v, w), Add(v, u, w);
  }
  DFS1(1, 0);
  DFS2(1, 0, 0);
  for (register long long i = 1; i <= n; i++)
    if (!root || F[i] < F[root]) root = i;
  for (register long long i = 1; i <= n; i++) g[i] = i;
  DFS3(root, 0);
  sort(g + 1, g + 1 + n, cp);
  Q = read();
  for (register long long i = 1; i <= Q; i++) {
    long long L = read();
    long long r = 1, res = 0;
    for (register long long j = 1; j <= n; j++) {
      while (r <= n && F[g[r]] - F[g[j]] <= L) A.Add(id[g[r]], 1), r++;
      res = max(res, A.Ask(id[g[j]] + siz[g[j]] - 1) - A.Ask(id[g[j]] - 1));
      A.Add(id[g[j]], -1);
    }
    printf("%lld\n", res);
  }
  return 0;
}
