#include <bits/stdc++.h>
using namespace std;
long long const N = 1e5 + 20;
long long n, q, d[N], par[N], a[N];
bool mark[N];
vector<pair<long long, long long> > g[N];
inline bool byd(long long x, long long y) { return d[x] < d[y]; }
void dfs(long long v, long long par = -1, long long D = 0) {
  for (auto ed : g[v]) {
    long long u, w;
    tie(u, w) = ed;
    if (u != par) {
      d[u] = max(d[u], D + w);
      dfs(u, v, D + w);
    }
  }
}
void pre() {
  long long root = 0;
  dfs(root);
  for (long long i = 0; i < n; i++)
    if (d[i] > d[root]) root = i;
  dfs(root);
  for (long long i = 0; i < n; i++)
    if (d[i] > d[root]) root = i;
  dfs(root);
  for (long long i = 0; i < n; i++) a[i] = i;
  sort(a, a + n, byd);
}
long long root(long long v) { return par[v] < 0 ? v : par[v] = root(par[v]); }
inline long long add(long long v) {
  mark[v] = 1;
  for (auto ed : g[v]) {
    long long u = ed.first;
    if (mark[u]) {
      par[v] += par[root(u)];
      par[root(u)] = v;
    }
  }
  return -par[v];
}
inline void rmv(long long v) { mark[v] = 0, par[root(v)]++; }
inline long long solve(long long l) {
  long long ans = 0, j = n - 1;
  memset(par, -1, sizeof par);
  for (long long i = n - 1; ~i; i--) {
    while (j >= 0 && d[a[i]] - d[a[j]] <= l) {
      ans = max(ans, add(a[j]));
      j--;
    }
    rmv(a[i]);
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  pre();
  cin >> q;
  while (q--) {
    long long l;
    cin >> l;
    cout << solve(l) << '\n';
  }
}
