#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, const U &b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, const U &b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T1, class T2>
inline void gn(T1 &x1, T2 &x2) {
  gn(x1), gn(x2);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
vector<pair<int, int> > adj[100100];
long long mx[100100][2];
void dfs(int u, int f = 0) {
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    if (v == f) continue;
    dfs(v, u);
    smax(mx[u][1], mx[v][0] + e.second);
    if (mx[u][0] < mx[u][1]) swap(mx[u][0], mx[u][1]);
  }
}
void redfs(int u, int f = 0, long long pre = 0) {
  smax(mx[u][1], pre);
  if (mx[u][0] < mx[u][1]) swap(mx[u][0], mx[u][1]);
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    if (v == f) continue;
    if (mx[u][0] == mx[v][0] + e.second)
      redfs(v, u, mx[u][1] + e.second);
    else
      redfs(v, u, mx[u][0] + e.second);
  }
}
int fa[100100];
void DFS(int u) {
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    if (v == fa[u]) continue;
    fa[v] = u;
    DFS(v);
  }
}
int id[100100], root[100100], cnt[100100];
int find(int u) { return root[u] == u ? u : root[u] = find(root[u]); }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v, w;
    gn(u, v);
    gn(w);
    adj[u].push_back(pair<int, int>(v, w));
    adj[v].push_back(pair<int, int>(u, w));
  }
  dfs(1);
  redfs(1);
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, [](int u, int v) { return *mx[u] < *mx[v]; });
  DFS(id[1]);
  int m;
  for (cin >> m; m--;) {
    long long L;
    gn(L);
    for (int i = 1; i <= n; i++) root[i] = i, cnt[i] = 0;
    int ans = 0;
    for (int l = n, r = n; l >= 1; l--) {
      while (*mx[id[r]] - *mx[id[l]] > L) {
        int u = find(id[r]);
        cnt[u]--;
        r--;
      }
      cnt[id[l]]++;
      smax(ans, cnt[id[l]]);
      root[id[l]] = fa[id[l]];
      cnt[fa[id[l]]] += cnt[id[l]];
    }
    printf("%d\n", ans);
  }
  return 0;
}
