#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 5;
inline long long read() {
  long long x = 0, f = 1;
  char p = getchar();
  while (!isdigit(p)) {
    if (p == '-') f = -1;
    p = getchar();
  }
  while (isdigit(p)) x = (x << 3) + (x << 1) + (p ^ 48), p = getchar();
  return x * f;
}
long long edge[maxn], head[maxn], ver[maxn], nxt[maxn], n, q, fa[maxn], ans;
long long cnt, d[maxn], d2[maxn], frm[maxn], id[maxn], f[maxn], siz[maxn], l;
inline void add(long long x, long long y, long long z) {
  nxt[++cnt] = head[x];
  head[x] = cnt;
  ver[cnt] = y;
  edge[cnt] = z;
}
inline long long chkmax(long long &x, long long &x2, long long y) {
  if (x < y) {
    x2 = x;
    x = y;
    return 1;
  }
  if (x2 < y) {
    x2 = y;
    return 2;
  }
  return 0;
}
inline void dfs_pre(long long x, long long fa) {
  for (long long i = head[x]; i; i = nxt[i]) {
    long long y = ver[i];
    if (y == fa) continue;
    dfs_pre(y, x);
    if (chkmax(d[x], d2[x], d[y] + edge[i]) == 1) frm[x] = y;
  }
}
inline void dfs(long long x, long long fa) {
  for (long long i = head[x]; i; i = nxt[i]) {
    long long y = ver[i];
    if (y == fa) continue;
    if (frm[x] == y) {
      if (chkmax(d[y], d2[y], d2[x] + edge[i]) == 1) frm[y] = x;
    } else if (chkmax(d[y], d2[y], d[x] + edge[i]) == 1)
      frm[y] = x;
    dfs(y, x);
  }
}
inline bool cmp(long long a, long long b) { return d[a] < d[b]; }
inline long long find(long long x) {
  if (f[x] == x)
    return x;
  else
    return f[x] = find(f[x]);
}
inline void merge(long long x, long long y) {
  x = find(x);
  y = find(y);
  if (siz[x] < siz[y]) swap(x, y);
  f[y] = x;
  siz[x] += siz[y];
}
inline void dfs2(long long x, long long per) {
  fa[x] = per;
  for (long long i = head[x]; i; i = nxt[i]) {
    long long y = ver[i];
    if (y == per) continue;
    dfs2(y, x);
  }
}
signed main() {
  n = read();
  for (long long i = 1, x, y, z; i < n; i++)
    x = read(), y = read(), z = read(), add(x, y, z), add(y, x, z);
  for (long long i = 1; i <= n; i++) id[i] = i;
  dfs_pre(1, 0);
  dfs(1, 0);
  sort(id + 1, id + 1 + n, cmp);
  dfs2(id[1], 0);
  q = read();
  while (q--) {
    l = read();
    ans = 0;
    for (long long i = 1; i <= n; i++) f[i] = i, siz[i] = 1;
    for (long long i = n, now = n; i >= 1; i--) {
      while (now && d[id[now]] > d[id[i]] + l) siz[find(id[now])]--, now--;
      ans = max(ans, siz[find(id[i])]);
      merge(id[i], fa[id[i]]);
    }
    cout << ans << endl;
  }
  return 0;
}
