#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 100;
const long long oo = 1e12;
vector<pair<int, int> > g[N];
int n;
long long dp_down[N];
long long dp_up[N];
pair<long long, int> dp[N];
void dfs_down(int v, int p) {
  for (pair<int, int> nei : g[v]) {
    int u = nei.first;
    int w = nei.second;
    if (p == u) continue;
    dfs_down(u, v);
    dp_down[v] = max(dp_down[v], w + dp_down[u]);
  }
}
void dfs_up(int v, int p) {
  long long mx1 = dp_up[v], mx2 = -1;
  for (pair<int, int> nei : g[v]) {
    int u = nei.first;
    int w = nei.second;
    if (p == u) continue;
    if (dp_down[u] + w >= mx1) {
      mx2 = mx1;
      mx1 = dp_down[u] + w;
    } else if (dp_down[u] + w >= mx2)
      mx2 = dp_down[u] + w;
  }
  for (pair<int, int> nei : g[v]) {
    int u = nei.first;
    int w = nei.second;
    if (p == u) continue;
    if (w + dp_down[u] < mx1)
      dp_up[u] = mx1 + w;
    else
      dp_up[u] = mx2 + w;
  }
  for (pair<int, int> nei : g[v]) {
    int u = nei.first;
    if (p == u) continue;
    dfs_up(u, v);
  }
}
int st[N], ft[N];
int T;
void dfs(int v, int p) {
  st[v] = T++;
  for (pair<int, int> nei : g[v]) {
    int u = nei.first;
    if (u != p) dfs(u, v);
  }
  ft[v] = T;
}
int fen[N];
void add(int p) {
  for (p++; p < N; p += p & -p) fen[p]++;
}
int get(int p) {
  int sum = 0;
  for (; p; p -= p & -p) sum += fen[p];
  return sum;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }
  dfs_down(0, -1);
  dfs_up(0, -1);
  long long mn = oo;
  int ind;
  for (int i = 0; i < n; ++i) {
    dp[i].first = max(dp_up[i], dp_down[i]);
    dp[i].second = i;
    if (dp[i].first < mn) {
      mn = dp[i].first;
      ind = i;
    }
  }
  dfs(ind, -1);
  sort(dp, dp + n);
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    long long L;
    cin >> L;
    memset(fen, 0, sizeof fen);
    int ans = -1;
    int t = 0;
    for (int i = 0; i < n; ++i) {
      while (t < n && dp[t].first - dp[i].first <= L) {
        add(st[dp[t].second]);
        t++;
      }
      ans = max(ans, get(ft[dp[i].second]) - get(st[dp[i].second]));
    }
    cout << ans << "\n";
  }
  return 0;
}
