#include <bits/stdc++.h>
using namespace std;
template <typename T>
void cmax(T &a, const T &b) {
  if (a < b) a = b;
}
using LL = long long;
constexpr int MAX_N = 1E5;
int n;
vector<pair<int, int>> e[MAX_N];
LL down[MAX_N][2], up[MAX_N];
LL c[MAX_N];
int parent[MAX_N][17], dep[MAX_N], k[MAX_N];
void dfs1(int u, int p) {
  for (auto pr : e[u]) {
    int v, w;
    tie(v, w) = pr;
    if (v == p) continue;
    dfs1(v, u);
    LL x = down[v][0] + w;
    if (x > down[u][0]) swap(x, down[u][0]);
    cmax(down[u][1], x);
  }
}
void dfs2(int u, int p) {
  for (auto pr : e[u]) {
    int v, w;
    tie(v, w) = pr;
    if (v == p) continue;
    up[v] =
        max(up[u], (down[v][0] + w == down[u][0] ? down[u][1] : down[u][0])) +
        w;
    dfs2(v, u);
  }
}
void dfs(int u) {
  for (int i = 1; (1 << i) <= dep[u]; ++i)
    parent[u][i] = parent[parent[u][i - 1]][i - 1];
  for (auto pr : e[u]) {
    int v, w;
    tie(v, w) = pr;
    if (v == parent[u][0]) continue;
    parent[v][0] = u;
    dep[v] = dep[u] + 1;
    dfs(v);
  }
}
void dfs0(int u) {
  for (auto pr : e[u]) {
    int v, w;
    tie(v, w) = pr;
    if (v == parent[u][0]) continue;
    dfs0(v);
    k[u] += k[v];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    --u;
    --v;
    e[u].emplace_back(v, w);
    e[v].emplace_back(u, w);
  }
  dfs1(0, -1);
  dfs2(0, -1);
  for (int i = 0; i < n; ++i) c[i] = max(up[i], down[i][0]);
  int rt = min_element(c, c + n) - c;
  parent[rt][0] = -1;
  dfs(rt);
  int q;
  cin >> q;
  while (q--) {
    LL l;
    cin >> l;
    memset(k, 0, n * sizeof(int));
    for (int i = 0; i < n; ++i) {
      int u = i;
      for (int j = 16; j >= 0; --j)
        if ((1 << j) <= dep[u] && c[i] - c[parent[u][j]] <= l) u = parent[u][j];
      ++k[i];
      u = parent[u][0];
      if (u != -1) --k[u];
    }
    dfs0(rt);
    cout << *max_element(k, k + n) << "\n";
  }
  return 0;
}
