#include <bits/stdc++.h>
template <typename Tp>
inline void read(Tp &x) {
  x = 0;
  bool f = true;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar()) f ^= ch == '-';
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + (ch ^ 48);
  x = f ? x : -x;
}
const int N = 1e5;
long long dis[N + 5], mx1[N + 5], mx2[N + 5], l;
std::vector<std::pair<int, int> > Vec[N + 5];
int fa[N + 5][20], dep[N + 5], sum[N + 5], ans;
void dfs1(int u, int ff) {
  for (int i = 0; i < (int)Vec[u].size(); ++i) {
    int v = Vec[u][i].first;
    if (v == ff) continue;
    dfs1(v, u);
    if (mx1[v] + Vec[u][i].second > mx1[u]) {
      mx2[u] = mx1[u];
      mx1[u] = mx1[v] + Vec[u][i].second;
    } else
      mx2[u] = std::max(mx2[u], mx1[v] + Vec[u][i].second);
  }
}
void dfs2(int u, int ff, long long diss) {
  dis[u] = std::max(diss, mx1[u]);
  for (int i = 0; i < (int)Vec[u].size(); ++i) {
    int v = Vec[u][i].first;
    if (v == ff) continue;
    if (mx1[v] + Vec[u][i].second == mx1[u])
      dfs2(v, u, std::max(diss, mx2[u]) + Vec[u][i].second);
    else
      dfs2(v, u, std::max(diss, mx1[u]) + Vec[u][i].second);
  }
}
void dfs3(int u) {
  for (int i = 1; (1 << i) < dep[u]; ++i) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (int i = 0; i < (int)Vec[u].size(); ++i) {
    int v = Vec[u][i].first;
    if (v == fa[u][0]) continue;
    fa[v][0] = u, dep[v] = dep[u] + 1;
    dfs3(v);
  }
}
void dfs4(int u) {
  int p = u;
  for (int i = 19; i >= 0; --i)
    if (fa[p][i] && dis[fa[p][i]] >= dis[u] - l) p = fa[p][i];
  ++sum[u], --sum[fa[p][0]];
  for (int i = 0; i < (int)Vec[u].size(); ++i) {
    int v = Vec[u][i].first;
    if (v == fa[u][0]) continue;
    dfs4(v);
  }
}
void dfs5(int u) {
  for (int i = 0; i < (int)Vec[u].size(); ++i) {
    int v = Vec[u][i].first;
    if (v == fa[u][0]) continue;
    dfs5(v);
    sum[u] += sum[v];
  }
  ans = std::max(ans, sum[u]);
}
int main() {
  int n;
  read(n);
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    read(u), read(v), read(w);
    Vec[u].push_back(std::make_pair(v, w)),
        Vec[v].push_back(std::make_pair(u, w));
  }
  dfs1(1, 0), dfs2(1, 0, 0);
  int rt = 1;
  for (int i = 2; i <= n; ++i)
    if (dis[i] < dis[rt]) rt = i;
  dep[rt] = 1;
  dfs3(rt);
  int q;
  read(q);
  while (q--) {
    read(l);
    memset(sum, 0, sizeof(sum));
    ans = 0;
    dfs4(rt), dfs5(rt);
    printf("%d\n", ans);
  }
  return 0;
}
