#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
long long n, q, l, ans;
vector<array<long long, 2>> adj[N];
long long tmp[N], dist[N], root, fa[N];
long long psum[N];
vector<array<long long, 2>> st;
void dfs1(long long v, long long p) {
  for (auto u : adj[v]) {
    if (u[0] == p) continue;
    tmp[u[0]] = tmp[v] + u[1];
    dfs1(u[0], v);
  }
}
void dfs2(long long v, long long p) {
  fa[v] = p;
  st.push_back(array<long long, 2>{dist[v], v});
  long long x = (*lower_bound(st.begin(), st.end(),
                              array<long long, 2>{dist[v] - l, 0}))[1];
  if (fa[x] >= 0) psum[fa[x]]--;
  psum[v]++;
  for (auto u : adj[v]) {
    if (u[0] == p) continue;
    dfs2(u[0], v);
  }
  st.pop_back();
}
void dfs3(long long v, long long p) {
  for (auto u : adj[v]) {
    if (u[0] == p) continue;
    dfs3(u[0], v);
    psum[v] += psum[u[0]];
  }
  ans = max(ans, psum[v]);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    --a, --b;
    adj[a].push_back({b, w});
    adj[b].push_back({a, w});
  }
  dfs1(0, -1);
  long long _u = max_element(tmp, tmp + n) - tmp;
  memset(tmp, 0, sizeof tmp);
  dfs1(_u, -1);
  long long _v = max_element(tmp, tmp + n) - tmp;
  swap(tmp, dist);
  dfs1(_v, -1);
  for (long long i = 0; i < n; i++) dist[i] = max(dist[i], tmp[i]);
  root = min_element(dist, dist + n) - dist;
  cin >> q;
  while (q--) {
    cin >> l;
    ans = 0;
    memset(psum, 0, sizeof psum);
    dfs2(root, -1);
    dfs3(root, -1);
    cout << ans << endl;
  }
}
