#include <bits/stdc++.h>
using namespace std;
struct st {
  int x;
  long long v;
  st(int xx, long long vv) { x = xx, v = vv; };
};
vector<st> adj[100005];
long long bst[100005] = {0};
int mxi;
void dfs(int x, int p, long long d) {
  bst[x] = max(d, bst[x]);
  if (bst[mxi] < bst[x]) mxi = x;
  int omar = adj[x].size();
  for (int i = 0; i < omar; ++i)
    if (adj[x][i].x != p) dfs(adj[x][i].x, x, adj[x][i].v + d);
}
int pi[100005], ri[100005], sz[100005];
int find(int x) { return (pi[x] == x) ? x : pi[x] = find(pi[x]); }
void merge(int x, int y) {
  x = find(x), y = find(y);
  if (ri[x] > ri[y])
    pi[y] = x, sz[x] += sz[y];
  else {
    if (ri[x] == ri[y]) ++ri[x];
    sz[y] += sz[x];
    pi[x] = y;
  }
}
pair<long long, int> ar[100005];
bool in[100005];
int n;
void init() {
  for (int i = 0; i <= n; ++i) {
    sz[i] = 1, ri[i] = 1, pi[i] = i;
  }
  memset(in, 0, sizeof(in));
}
int solve(long long L) {
  int ans = 0;
  init();
  int l = n;
  for (int i = n; i > 0; --i) {
    while (ar[l].first - ar[i].first > L) {
      sz[find(ar[l].second)]--;
      in[ar[l].second] = 0;
      --l;
    }
    in[ar[i].second] = 1;
    int omar = adj[ar[i].second].size();
    for (int j = 0; j < omar; ++j)
      if (in[adj[ar[i].second][j].x])
        merge(ar[i].second, adj[ar[i].second][j].x);
    ans = max(ans, sz[find(ar[i].second)]);
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    long long val;
    scanf("%d%d%I64d", &u, &v, &val);
    adj[u].push_back(st(v, val));
    adj[v].push_back(st(u, val));
  }
  mxi = 1;
  dfs(mxi, -1, 0);
  dfs(mxi, -1, 0);
  dfs(mxi, -1, 0);
  for (int i = 1; i <= n; ++i) ar[i].first = bst[i], ar[i].second = i;
  sort(ar + 1, ar + 1 + n);
  int t;
  cin >> t;
  while (t--) {
    long long L;
    cin >> L;
    cout << solve(L) << endl;
  }
}
