#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 500;
int tot = 0, To[N * 2], nx[N * 2], lst[N], w[N * 2], pa[N], sz[N], In[N], fa[N],
    n, son[N];
long long f[N], g[N], pre[N], suc[N];
pair<long long, int> a[N];
inline long long max3(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
int efind(int x) { return pa[x] == x ? x : pa[x] = efind(pa[x]); }
void Decrease(int x) {
  x = efind(x);
  --sz[x];
}
void Union(int x, int y) {
  x = efind(x), y = efind(y);
  if (x ^ y) pa[y] = x, sz[x] += sz[y];
}
void add(int x, int y, int z) {
  ++tot;
  To[tot] = y, nx[tot] = lst[x], lst[x] = tot;
  w[tot] = z;
}
void dfs1(int t) {
  g[t] = 0;
  for (int i = lst[t]; i; i = nx[i])
    if (To[i] ^ fa[t]) {
      fa[To[i]] = t;
      dfs1(To[i]);
      g[t] = max(g[t], g[To[i]] + w[i]);
    }
}
void dfs2(int t) {
  int n = 0;
  for (int i = lst[t]; i; i = nx[i])
    if (To[i] ^ fa[t]) son[++n] = i;
  pre[0] = 0;
  for (int i = 1; i <= n; i++)
    pre[i] = max(pre[i - 1], g[To[son[i]]] + w[son[i]]);
  suc[n + 1] = 0;
  for (int i = n; i >= 1; i--)
    suc[i] = max(suc[i + 1], g[To[son[i]]] + w[son[i]]);
  for (int i = 1; i <= n; i++) {
    f[To[son[i]]] = max3(pre[i - 1], suc[i + 1], f[t]) + w[son[i]];
  }
  for (int i = lst[t]; i; i = nx[i])
    if (To[i] ^ fa[t]) dfs2(To[i]);
  f[t] = max(f[t], g[t]);
}
void get_fa(int t) {
  for (int i = lst[t]; i; i = nx[i])
    if (To[i] ^ fa[t]) {
      fa[To[i]] = t;
      get_fa(To[i]);
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z);
    add(y, x, z);
    In[x]++;
    In[y]++;
  }
  int rt = 1;
  for (int i = 1; i <= n; i++)
    if (In[i] > 1) {
      rt = i;
      break;
    }
  dfs1(rt);
  dfs2(rt);
  for (int i = 1; i <= n; i++)
    if (f[i] < f[rt]) rt = i;
  fa[rt] = 0;
  get_fa(rt);
  for (int i = 1; i <= n; i++) a[i] = make_pair(f[i], i);
  sort(a + 1, a + n + 1, greater<pair<long long, int> >());
  int Qn;
  scanf("%d", &Qn);
  while (Qn--) {
    long long lim;
    scanf("%lld", &lim);
    for (int i = 1; i <= n; i++) pa[i] = i, sz[i] = 1;
    int j = 1, ans = 0;
    for (int i = 1; i <= n; i++) {
      int t = a[i].second;
      for (int j = lst[t]; j; j = nx[j])
        if (To[j] ^ fa[t]) Union(To[j], t);
      while (a[j].first > a[i].first + lim) {
        Decrease(a[j].second);
        ++j;
      }
      ans = max(ans, sz[efind(t)]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
