#include <bits/stdc++.h>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1e9 + 100;
const long long LINF = 1e18 + 100;
int n;
vector<pair<int, int> > adj[100100];
long long down[100100], up[100100], far[100100], down2[100100];
int rt;
long long L;
vector<int> ord;
int par[100100], h[100100];
int sz[100100], dpar[100100];
int getroot(int x) { return dpar[x] == x ? x : dpar[x] = getroot(dpar[x]); }
void merge(int x, int y) {
  x = getroot(x);
  y = getroot(y);
  if (x == y) return;
  dpar[x] = y;
  sz[y] += sz[x];
}
void dfsdown(int v, int par) {
  for (pair<int, int> p : adj[v])
    if (p.first != par) {
      dfsdown(p.first, v);
      long long val = down[p.first] + p.second;
      if (val >= down[v])
        down2[v] = down[v], down[v] = val;
      else
        down2[v] = max(down2[v], val);
    }
}
void dfsup(int v, int par, int wpar) {
  if (par >= 0) up[v] = up[par] + wpar;
  if (down[v] + wpar == down[par])
    up[v] = max(up[v], down2[par] + wpar);
  else
    up[v] = max(up[v], down[par] + wpar);
  for (pair<int, int> p : adj[v])
    if (p.first != par) dfsup(p.first, v, p.second);
}
void dfs(int v) {
  for (pair<int, int> p : adj[v])
    if (p.first != par[v]) {
      int u = p.first;
      par[u] = v;
      h[u] = h[v] + 1;
      dfs(u);
    }
}
int32_t main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = (0); i < (int)(n - 1); i++) {
    int x, y, w;
    cin >> x >> y >> w;
    adj[x].push_back({y, w});
    adj[y].push_back({x, w});
  }
  dfsdown(1, -1);
  dfsup(1, -1, 0);
  for (int v = (1); v < (int)(n + 1); v++) far[v] = max(up[v], down[v]);
  ;
  ;
  rt = min_element(far + 1, far + n + 1) - far;
  ;
  ;
  dfs(rt);
  ord.resize(n);
  iota((ord).begin(), (ord).end(), 1);
  sort((ord).begin(), (ord).end(), [&](int x, int y) {
    return far[x] == far[y] ? h[x] > h[y] : far[x] > far[y];
  });
  ;
  ;
  int q;
  cin >> q;
  while (q--) {
    cin >> L;
    fill(sz, sz + n + 10, 1);
    iota(dpar, dpar + n + 10, 0);
    int ans = 0;
    int ptr = 0;
    for (int v : ord) {
      for (pair<int, int> p : adj[v])
        if (p.first != par[v]) merge(p.first, v);
      while (ptr < n && far[ord[ptr]] > far[v] + L)
        sz[getroot(ord[ptr])]--, ptr++;
      ans = max(ans, sz[getroot(v)]);
    }
    cout << ans << '\n';
  }
  return 0;
}
