#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> q[100100];
long long n, m, Q, L, d[100100], rt, ans;
vector<pair<long long, long long> > v[100100];
inline void dfs(long long x, long long fa) {
  for (long long i = 0; i < v[x].size(); i++)
    if (v[x][i].first != fa) {
      long long y = v[x][i].first, z = v[x][i].second;
      d[y] = d[x] + z;
      dfs(y, x);
    }
}
inline void dfs2(long long x, long long fa, long long sum) {
  d[x] = max(d[x], sum);
  for (long long i = 0; i < v[x].size(); i++)
    if (v[x][i].first != fa) {
      long long y = v[x][i].first, z = v[x][i].second;
      dfs2(y, x, sum + z);
    }
}
inline void mer(priority_queue<long long> &x, priority_queue<long long> &y) {
  if ((long long)y.size() > (long long)x.size()) swap(x, y);
  while (!y.empty()) x.push(y.top()), y.pop();
}
inline void go(long long x, long long fa) {
  for (long long i = 0; i < v[x].size(); i++)
    if (v[x][i].first != fa) {
      long long y = v[x][i].first, z = v[x][i].second;
      go(y, x);
      mer(q[x], q[y]);
      while (!q[x].empty())
        if (q[x].top() - d[x] > L)
          q[x].pop();
        else
          break;
    }
  ans = max(ans, (long long)q[x].size());
  return;
}
signed main() {
  long long i, j, k;
  rt = 1;
  scanf("%lld", &n);
  for (i = 1; i < n; i++) {
    long long x, y, z;
    scanf("%lld%lld%lld", &x, &y, &z);
    v[x].push_back(make_pair(y, z));
    v[y].push_back(make_pair(x, z));
  }
  dfs(rt, 0);
  for (i = 1; i <= n; i++)
    if (d[i] > d[rt]) rt = i;
  memset(d, 0, sizeof(d));
  dfs(rt, 0);
  long long ano = rt;
  for (i = 1; i <= n; i++)
    if (d[i] > d[ano]) ano = i;
  dfs2(ano, 0, 0);
  for (i = 1; i <= n; i++)
    if (d[i] < d[rt]) rt = i;
  scanf("%lld", &Q);
  while (Q--) {
    for (i = 1; i <= n; i++) {
      while (!q[i].empty()) q[i].pop();
      q[i].push(d[i]);
    }
    scanf("%lld", &L);
    ans = 0;
    go(rt, 0);
    printf("%lld\n", ans);
  }
  return 0;
}
