#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, M = 2e5 + 10;
long long inf = 1e11 + 10;
int n, d[N], st[N][20];
int e, to[M], nxt[M], hd[N], val[M];
long long disp[N], disq[N], f[N], dis[N];
void add(int a, int b, int c) {
  to[++e] = b;
  val[e] = c;
  nxt[e] = hd[a];
  hd[a] = e;
}
int dd, rt;
long long mx;
void dfs(int u, int fa, long long sum, int tp) {
  if (sum > mx) mx = sum, dd = u;
  if (tp == 0)
    disp[u] = sum;
  else if (tp == 1)
    disq[u] = sum;
  for (int i = hd[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa) continue;
    dfs(v, u, sum + val[i], tp);
  }
  return;
}
void findrt() {
  int p, q;
  mx = dd = 0;
  dfs(1, 0, 0, -1);
  p = dd;
  mx = dd = 0;
  dfs(p, 0, 0, 0);
  q = dd;
  dfs(q, 0, 0, 1);
  rt = 0;
  f[0] = inf;
  for (int i = 1; i <= n; i++) {
    f[i] = max(disp[i], disq[i]);
    if (f[i] < f[rt]) rt = i;
  }
  f[0] = -inf;
  return;
}
void dfs2(int u, int fa) {
  st[u][0] = fa;
  for (int i = 1; i <= 17; i++) st[u][i] = st[st[u][i - 1]][i - 1];
  for (int i = hd[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa) continue;
    dis[v] = dis[u] + val[i];
    dfs2(v, u);
  }
  return;
}
void init() {
  findrt();
  dfs2(rt, 0);
}
int findfa(int u, long long l) {
  int t = u;
  for (int i = 17; i >= 0; i--) {
    int v = st[t][i];
    if (f[u] - f[v] <= l) t = v;
  }
  return t;
}
int ans;
void dfscalc(int u, int fa) {
  for (int i = hd[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa) continue;
    dfscalc(v, u);
    d[u] += d[v];
  }
  if (d[u] > ans) ans = d[u];
  return;
}
int solve(long long l) {
  for (int i = 0; i <= n; i++) d[i] = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = findfa(i, l);
    d[st[tmp][0]]--;
    d[i]++;
  }
  ans = 0;
  dfscalc(rt, 0);
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y, z; i < n; i++) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z), add(y, x, z);
  }
  init();
  int q;
  scanf("%d", &q);
  while (q--) {
    long long l;
    scanf("%lld", &l);
    printf("%d\n", solve(l));
  }
  return 0;
}
