#include <bits/stdc++.h>
using namespace std;
int n, q, LN, RN, RT, fa[100005][20], ans;
long long disl[100005], disr[100005], f[100005];
vector<pair<int, long long> > to[100005];
pair<int, long long> dfs(int p, int f, long long dep, long long *dis) {
  pair<int, long long> res = make_pair(p, dep);
  dis[p] = dep;
  for (int i = 0; i < to[p].size(); i++)
    if (to[p][i].first != f) {
      pair<int, long long> o =
          dfs(to[p][i].first, p, dep + to[p][i].second, dis);
      if (o.second > res.second) res = o;
    }
  return res;
}
void dfn(int p, int f) {
  fa[p][0] = f;
  for (int i = 1; fa[fa[p][i - 1]][i - 1]; i++)
    fa[p][i] = fa[fa[p][i - 1]][i - 1];
  for (int i = 0; i < to[p].size(); i++)
    if (to[p][i].first != f) dfn(to[p][i].first, p);
}
int s[100005];
void Dfs(int p, long long u) {
  int v = p;
  for (int i = 19; i >= 0; i--)
    if (fa[v][i] && f[p] - f[fa[v][i]] <= u) v = fa[v][i];
  s[p]++;
  s[fa[v][0]]--;
  for (int i = 0; i < to[p].size(); i++)
    if (to[p][i].first != fa[p][0]) Dfs(to[p][i].first, u);
}
void DFS(int p) {
  for (int i = 0; i < to[p].size(); i++)
    if (to[p][i].first != fa[p][0]) {
      DFS(to[p][i].first);
      s[p] += s[to[p][i].first];
    }
  ans = max(ans, s[p]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1, u, v, w; i < n; i++) {
    cin >> u >> v >> w;
    to[u].push_back(make_pair(v, w));
    to[v].push_back(make_pair(u, w));
  }
  LN = dfs(1, 0, 0, disl).first;
  RN = dfs(LN, 0, 0, disl).first;
  dfs(RN, 0, 0, disr);
  RT = 1;
  for (int i = 1; i <= n; i++) f[i] = max(disl[i], disr[i]);
  for (int i = 2; i <= n; i++)
    if (f[i] < f[RT]) RT = i;
  dfn(RT, 0);
  cin >> q;
  while (q--) {
    long long u;
    cin >> u;
    ans = 0;
    memset(s, 0, sizeof(s));
    Dfs(RT, u);
    DFS(RT);
    cout << ans << '\n';
  }
}
