#include <bits/stdc++.h>
using namespace std;
const int N = 1E5 + 10;
int n;
int idx[N];
long long depth[N];
bool avail[N];
vector<pair<long long, int> > adj[N];
struct DSU {
  int par[N];
  void Init() { memset(par, -1, sizeof(par)); }
  int Root(int u) {
    if (par[u] < 0) return u;
    return par[u] = Root(par[u]);
  }
  void Union(int x, int y) {
    x = Root(x);
    y = Root(y);
    if (x == y) return;
    par[x] += par[y];
    par[y] = x;
  }
} DSU;
void Read_Input() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    adj[u].push_back(pair<long long, int>(v, w));
    adj[v].push_back(pair<long long, int>(u, w));
  }
}
void DFS(int u, int p, long long d) {
  depth[u] = max(depth[u], d);
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    int w = adj[u][i].second;
    if (v == p) continue;
    DFS(v, u, d + w);
  }
}
bool cmp(int x, int y) { return depth[x] > depth[y]; }
void Init() {
  DFS(1, -1, 0);
  DFS(max_element(depth + 1, depth + 1 + n) - depth, -1, 0);
  DFS(max_element(depth + 1, depth + 1 + n) - depth, -1, 0);
  for (int i = 1; i <= n; i++) idx[i] = i;
  sort(idx + 1, idx + 1 + n, cmp);
}
int Add(int u) {
  avail[u] = true;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    if (!avail[v]) continue;
    DSU.Union(u, v);
  }
  return -DSU.par[DSU.Root(u)];
}
void Remove(int u) {
  avail[u] = false;
  DSU.par[DSU.Root(u)]++;
}
void Solve() {
  int TC;
  scanf("%d", &TC);
  while (TC--) {
    DSU.Init();
    memset(avail, false, sizeof(avail));
    long long len;
    scanf("%I64d", &len);
    int j = 1, ans = 0;
    for (int i = 1; i <= n; i++) {
      while (j <= n && depth[idx[i]] - depth[idx[j]] <= len)
        ans = max(ans, Add(idx[j++]));
      Remove(idx[i]);
    }
    printf("%d\n", ans);
  }
}
int main() {
  Read_Input();
  Init();
  Solve();
  return 0;
}
