#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (b < a) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (b > a) a = b;
}
int N, Q, S, T, R, K;
vector<pair<int, int> > edge[100013];
long long dist[2][100013];
int ord[100013];
int parent[100013], st[100013], ft[100013];
pair<long long, long long> adds[100013], subs[100013];
int best[100013];
bool cmp(int i, int j) {
  return max(dist[0][i], dist[1][i]) < max(dist[0][j], dist[1][j]);
}
void dfs(int u, int pa, bool f) {
  for (auto p : edge[u]) {
    long long d = p.first;
    int v = p.second;
    if (v == pa) continue;
    dist[f][v] = dist[f][u] + d;
    dfs(v, u, f);
  }
}
void dfs1(int u) {
  st[u] = K;
  ft[u] = K;
  K++;
  for (auto p : edge[u]) {
    int v = p.second;
    if (v == parent[u]) continue;
    parent[v] = u;
    dfs1(v);
    ft[u] = ft[v];
  }
}
int fen[100013];
void update(int idx, int v) {
  for (int e = idx + 1; e <= N + 1; e += e & (-e)) fen[e] += v;
}
int query(int idx) {
  int res = 0;
  for (int e = idx + 1; e; e -= e & (-e)) res += fen[e];
  return res;
}
int solve(long long x) {
  int res = 0;
  for (auto i = (0); i < (N); i++) {
    subs[i] = {max(dist[0][i], dist[1][i]) - 1, i};
    adds[i] = {max(dist[0][i], dist[1][i]) + x, i};
    best[i] = 0;
  }
  for (auto i = (0); i < (N + 2); i++) fen[i] = 0;
  sort(subs, subs + N);
  sort(adds, adds + N);
  int its = 0, ita = 0;
  for (auto i = (0); i < (N); i++) {
    int u = ord[i];
    long long t = max(dist[0][u], dist[1][u]);
    while (ita < N && adds[ita].first < t) {
      int v = adds[ita].second;
      best[v] += (query(ft[v]) - query(st[v] - 1));
      ita++;
    }
    while (its < N && subs[its].first < t) {
      int v = subs[its].second;
      best[v] -= (query(ft[v]) - query(st[v] - 1));
      its++;
    }
    update(st[u], 1);
  }
  while (ita < N) {
    int v = adds[ita].second;
    best[v] += (query(ft[v]) - query(st[v] - 1));
    ita++;
  }
  while (its < N) {
    int v = subs[its].second;
    best[v] -= (query(ft[v]) - query(st[v] - 1));
    its++;
  }
  for (auto i = (0); i < (N); i++) {
    ckmax(res, best[i]);
  }
  return res;
}
int32_t main() {
  cin >> N;
  for (auto i = (0); i < (N - 1); i++) {
    int u, v, d;
    cin >> u >> v >> d;
    u--;
    v--;
    edge[u].push_back({d, v});
    edge[v].push_back({d, u});
  }
  dist[1][0] = 0;
  dfs(0, N, 1);
  for (auto i = (0); i < (N); i++) {
    if (dist[1][i] > dist[1][S]) S = i;
  }
  dist[0][S] = 0;
  dfs(S, N, 0);
  for (auto i = (0); i < (N); i++) {
    if (dist[0][i] > dist[0][T]) T = i;
  }
  dist[1][T] = 0;
  dfs(T, N, 1);
  for (auto i = (0); i < (N); i++) {
    if (max(dist[0][i], dist[1][i]) < max(dist[0][R], dist[1][R])) R = i;
  }
  for (auto i = (0); i < (N); i++) parent[i] = N;
  dfs1(R);
  for (auto i = (0); i < (N); i++) ord[i] = i;
  sort(ord, ord + N, cmp);
  cin >> Q;
  while (Q--) {
    long long x;
    cin >> x;
    cout << solve(x) << '\n';
  }
  return 0;
}
