#include <bits/stdc++.h>
using namespace std;
long long read() {
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  long long x = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}
const int N = 1e5 + 5;
int t[N << 1], nxt[N << 1], v[N << 1], lst[N], l;
void add(int x, int y, int z) {
  t[++l] = y;
  v[l] = z;
  nxt[l] = lst[x];
  lst[x] = l;
}
int n, dep[N], fa[N][17], cnt[N];
long long sum[N], dis[N];
void dfs(int x, int y) {
  fa[x][0] = y;
  dep[x] = dep[y] + 1;
  for (int j = 1; j <= 16; j++) fa[x][j] = fa[fa[x][j - 1]][j - 1];
  for (int i = lst[x]; i; i = nxt[i])
    if (t[i] != y) sum[t[i]] = sum[x] + v[i], dfs(t[i], x);
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int j = 16; j >= 0; j--)
    if (dep[fa[x][j]] > dep[y]) x = fa[x][j];
  x = dep[x] == dep[y] ? x : fa[x][0];
  for (int j = 16; j >= 0; j--)
    if (fa[x][j] != fa[y][j]) x = fa[x][j], y = fa[y][j];
  return x == y ? x : fa[x][0];
}
long long dist(int x, int y) {
  int z = lca(x, y);
  return sum[x] + sum[y] - 2 * sum[z];
}
int find_d(int x) {
  long long mx = 0;
  int id = 0;
  for (int i = 1; i <= n; i++) {
    long long d = dist(x, i);
    if (d > mx) mx = d, id = i;
  }
  return id;
}
void get_ans(int x, int y) {
  for (int i = lst[x]; i; i = nxt[i])
    if (t[i] != y) get_ans(t[i], x), cnt[x] += cnt[t[i]];
}
int main() {
  n = read();
  for (int i = 1; i <= n - 1; i++) {
    int x = read(), y = read(), z = read();
    add(x, y, z);
    add(y, x, z);
  }
  sum[1] = dep[1] = 0;
  dfs(1, 0);
  int x = find_d(1), y = find_d(x);
  for (int i = 1; i <= n; i++) dis[i] = max(dist(i, x), dist(i, y));
  int id = 0;
  long long mn = 1e18;
  for (int i = 1; i <= n; i++)
    if (dis[i] < mn) mn = dis[i], id = i;
  sum[id] = dep[id] = 0;
  dfs(id, 0);
  for (int q = read(); q; q--) {
    long long len = read();
    for (int i = 1; i <= n; i++) cnt[i] = 0;
    for (int i = 1; i <= n; i++) {
      int x = i;
      for (int j = 16; j >= 0; j--)
        if (fa[x][j] && dis[i] - dis[fa[x][j]] <= len) x = fa[x][j];
      cnt[i]++;
      cnt[fa[x][0]]--;
    }
    get_ans(id, 0);
    int ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, cnt[i]);
    printf("%d\n", ans);
  }
  return 0;
}
