#include <bits/stdc++.h>
using namespace std;
const int MAX = 100100;
const long long oo = 1e17;
int N, Q;
int size[MAX];
long long h[MAX];
long long far[MAX];
struct Edge {
  int y, w;
};
vector<Edge> adj[MAX];
void init(int x, int dad) {
  for (Edge e : adj[x]) {
    if (e.y == dad) continue;
    init(e.y, x);
    h[x] = max(h[x], h[e.y] + e.w);
  }
}
void calc_size(int x, int dad) {
  size[x] = 1;
  for (Edge e : adj[x]) {
    if (e.y == dad) continue;
    calc_size(e.y, x);
    size[x] += size[e.y];
  }
}
void rec(int x, int dad, long long up) {
  long long m1 = -oo;
  long long m2 = -oo;
  far[x] = up;
  for (Edge e : adj[x]) {
    if (e.y == dad) continue;
    long long v = h[e.y] + e.w;
    far[x] = max(far[x], v);
    if (v >= m1) {
      m2 = m1;
      m1 = v;
    } else if (v >= m2) {
      m2 = v;
    }
  }
  for (Edge e : adj[x]) {
    if (e.y == dad) continue;
    long long v = h[e.y] + e.w;
    long long u = up;
    if (v == m1)
      u = max(u, m2);
    else
      u = max(u, m1);
    u += e.w;
    rec(e.y, x, u);
  }
}
long long D;
int ans;
void insert(int x, int dad, priority_queue<long long> &Q, long long bound) {
  if (far[x] > bound) return;
  Q.push(far[x]);
  for (Edge e : adj[x]) {
    if (e.y == dad) continue;
    insert(e.y, x, Q, bound);
  }
}
void solve(int x, int dad, priority_queue<long long> &Q) {
  int maks = -1;
  for (Edge e : adj[x]) {
    if (e.y == dad) continue;
    if (maks == -1 || size[e.y] > size[maks]) maks = e.y;
  }
  for (Edge e : adj[x]) {
    if (e.y == dad || e.y == maks) continue;
    priority_queue<long long> tmp;
    solve(e.y, x, tmp);
  }
  if (maks != -1) solve(maks, x, Q);
  Q.push(far[x]);
  while (Q.top() - far[x] > D) Q.pop();
  for (Edge e : adj[x]) {
    if (e.y == dad || e.y == maks) continue;
    insert(e.y, x, Q, far[x] + D);
  }
  ans = max(ans, (int)Q.size());
}
int main() {
  scanf("%d", &N);
  for (int i = (0); i < (N - 1); ++i) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    --x, --y;
    adj[x].push_back({y, w});
    adj[y].push_back({x, w});
  }
  init(0, -1);
  rec(0, -1, 0);
  long long mini = oo;
  for (int i = (0); i < (N); ++i) mini = min(mini, far[i]);
  int K = 0;
  for (int i = (0); i < (N); ++i)
    if (far[i] == mini) K = i;
  calc_size(K, -1);
  scanf("%d", &Q);
  for (int i = (0); i < (Q); ++i) {
    scanf("%lld", &D);
    ans = 1;
    priority_queue<long long> Q;
    solve(K, -1, Q);
    printf("%d\n", ans);
  }
  return 0;
}
