#include <bits/stdc++.h>
using namespace std;
const int Max_N(100050);
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = x * 10 + (c & 15);
  x *= f;
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io::gi;
using io::print;
using io::putc;
int N, Q, Head[Max_N], Total, To[Max_N << 1], Next[Max_N << 1],
    Weight[Max_N << 1], root;
long long int Dist[Max_N], Val[Max_N];
inline void Add_Edge(int s, int t, int w) {
  ++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total,
           Weight[Total] = w;
}
void dfs(int u, int fa) {
  for (int i = Head[u], v; i; i = Next[i])
    if ((v = To[i]) != fa) Dist[v] = Dist[u] + Weight[i], dfs(v, u);
}
int P[Max_N], Father[Max_N], Size[Max_N];
bool done[Max_N];
int Get_Father(int x) {
  return Father[x] == x ? x : Father[x] = Get_Father(Father[x]);
}
inline bool comp(int a, int b) { return Val[a] < Val[b]; }
int main() {
  gi(N);
  for (int i = 1, x, y, w; i <= N - 1; ++i)
    gi(x), gi(y), gi(w), Add_Edge(x, y, w), Add_Edge(y, x, w);
  Dist[1] = 0LL, dfs(1, -1);
  root = 1;
  for (int u = 2; u <= N; ++u)
    if (Dist[u] > Dist[root]) root = u;
  Dist[root] = 0LL, dfs(root, -1);
  for (int u = 1; u <= N; ++u) {
    Val[u] = Dist[u];
    if (Dist[u] > Dist[root]) root = u;
  }
  Dist[root] = 0LL, dfs(root, -1), root = 1;
  for (int u = 1; u <= N; ++u) {
    Val[u] = max(Val[u], Dist[u]);
    if (Val[u] < Val[root]) root = u;
    P[u] = u;
  }
  sort(P + 1, P + 1 + N, comp);
  gi(Q);
  for (long long int L; Q--;) {
    gi(L);
    for (int u = 1; u <= N; ++u) Father[u] = u, Size[u] = 1, done[u] = false;
    int Ans = 0;
    for (int i = N, j = N, u; i >= 1; --i) {
      done[u = P[i]] = true;
      for (int i = Head[u], v; i; i = Next[i])
        if (done[v = To[i]]) Father[v] = u, Size[u] += Size[v];
      while (Val[P[j]] - Val[P[i]] > L)
        --Size[Get_Father(P[j])], done[P[j]] = false, --j;
      Ans = max(Ans, Size[u]);
    }
    print(Ans), putc('\n');
  }
  return 0;
}
