#include <bits/stdc++.h>
using namespace std;
long long n;
const long long N = 1e5 + 10;
struct bian {
  long long from, to, w;
} eg[N << 1];
long long front[N], num;
void add(long long x, long long y, long long w) {
  eg[++num].to = y;
  eg[num].from = front[x];
  front[x] = num;
  eg[num].w = w;
}
long long f[N];
long long p, q, maxs;
void dfs1(long long o, long long from, long long dis) {
  f[o] = max(f[o], dis);
  if (dis > maxs) {
    p = o;
    maxs = dis;
  }
  for (long long i = front[o]; i; i = eg[i].from) {
    long long to = eg[i].to;
    if (to == from) continue;
    dfs1(to, o, dis + eg[i].w);
  }
}
void dfs2(long long o, long long from, long long dis) {
  f[o] = max(f[o], dis);
  if (dis > maxs) {
    q = o;
    maxs = dis;
  }
  for (long long i = front[o]; i; i = eg[i].from) {
    long long to = eg[i].to;
    if (to == from) continue;
    dfs2(to, o, dis + eg[i].w);
  }
}
void dfs3(long long o, long long from, long long dis) {
  f[o] = max(f[o], dis);
  for (long long i = front[o]; i; i = eg[i].from) {
    long long to = eg[i].to;
    if (to == from) continue;
    dfs3(to, o, dis + eg[i].w);
  }
}
long long dis[N], ids[N], ans;
long long val[N], dep[N];
void dfs(long long o, long long from, long long x) {
  dep[o] = dep[from] + 1;
  dis[dep[o]] = f[o];
  ids[dep[o]] = o;
  val[o] += 1;
  val[ids[lower_bound(dis, dis + dep[o] + 1, f[o] - x) - dis - 1]] -= 1;
  for (long long i = front[o]; i; i = eg[i].from) {
    long long to = eg[i].to;
    if (to == from) continue;
    dfs(to, o, x);
    val[o] += val[to];
  }
  ans = max(ans, val[o]);
}
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i < n; ++i) {
    long long x, y, w;
    scanf("%lld%lld%lld", &x, &y, &w);
    add(x, y, w);
    add(y, x, w);
  }
  dfs1(1, 0, 0);
  maxs = 0;
  dfs2(p, 0, 0);
  dfs3(q, 0, 0);
  long long root = 1;
  for (long long i = 2; i <= n; ++i) {
    if (f[i] < f[root]) root = i;
  }
  dis[0] = -1e11;
  scanf("%lld", &q);
  while (q--) {
    memset(val, 0, sizeof(val));
    long long w;
    scanf("%lld", &w);
    ans = 0;
    dfs(root, 0, w);
    printf("%lld\n", ans);
  }
}
