#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  char c;
  int positive = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') positive = 0;
  do x = x * 10 + c - '0';
  while (isdigit(c = getchar()));
  if (!positive) x = -x;
}
template <typename T>
inline void write(T x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
const int maxn = 100010;
long long f[maxn][2];
pair<long long, int> far[maxn];
int n;
vector<pair<int, int> > a[maxn];
int pa[maxn];
void input() {
  read(n);
  for (int i = (1), _b = (n); i < _b; i++) {
    int u, v, c;
    read(u);
    read(v);
    read(c);
    a[u].push_back(pair<int, int>(v, c));
    a[v].push_back(pair<int, int>(u, c));
  }
}
void init() {}
void dfs(int u, int fa) {
  for (int i = (0), _b = (int((a[u]).size())); i < _b; i++) {
    int v = a[u][i].first, c = a[u][i].second;
    if (v == fa) continue;
    dfs(v, u);
    if (f[u][0] < f[v][0] + c) {
      f[u][1] = f[u][0];
      f[u][0] = f[v][0] + c;
    } else if (f[u][1] < f[v][0] + c)
      f[u][1] = f[v][0] + c;
  }
}
void dfs(int u, int fa, long long dist) {
  far[u].first = max(dist, f[u][0]);
  for (int i = (0), _b = (int((a[u]).size())); i < _b; i++) {
    int v = a[u][i].first, c = a[u][i].second;
    if (v == fa) continue;
    if (f[v][0] + c == f[u][0])
      dfs(v, u, max(f[u][1], dist) + c);
    else
      dfs(v, u, max(f[u][0], dist) + c);
  }
}
void dfs2(int u, int fa) {
  pa[u] = fa;
  for (int i = (0), _b = (int((a[u]).size())); i < _b; i++) {
    int v = a[u][i].first;
    if (v != fa) dfs2(v, u);
  }
}
struct union_find {
  int num[maxn], lab[maxn], v[maxn];
  void init(int n) {
    for (int i = (1), _b = (n); i <= _b; i++) num[i] = 1, lab[i] = i, v[i] = 1;
  }
  int getroot(int x) { return x != lab[x] ? lab[x] = getroot(lab[x]) : x; }
  void unite(int x, int y) {
    x = getroot(x);
    y = getroot(y);
    if (x == y) return;
    if (num[x] < num[y])
      num[y] += num[x], lab[x] = y, v[y] += v[x];
    else
      num[x] += num[y], lab[y] = x, v[x] += v[y];
  }
} u;
void solve() {
  dfs(1, 0);
  dfs(1, 0, 0);
  int root;
  long long mi = 1e18, ma = 0;
  for (int i = (1), _b = (n); i <= _b; i++) {
    if (far[i].first < mi) mi = far[i].first, root = i;
    ma = max(ma, far[i].first);
  }
  dfs2(root, root);
  for (int i = (1), _b = (n); i <= _b; i++) far[i].second = i;
  sort(far + 1, far + 1 + n);
  int q;
  read(q);
  while (q--) {
    long long len;
    read(len);
    int ans = 0;
    int it = n;
    u.init(n);
    for (int i = (n), _a = (1); i >= _a; i--) {
      int me = far[i].second;
      for (int j = (0), _b = (int((a[me]).size())); j < _b; j++) {
        int v = a[me][j].first;
        if (v == pa[me]) continue;
        u.unite(me, v);
      }
      while (far[it].first - far[i].first > len) {
        u.v[u.getroot(far[it].second)]--;
        it--;
      }
      ans = max(ans, u.v[u.getroot(me)]);
    }
    write(ans);
    putchar('\n');
  }
}
int main() {
  clock_t timestart, timeend;
  timestart = clock();
  input();
  init();
  solve();
  timeend = clock();
  return 0;
}
