#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct BIT {
  int d[N];
  void reset() {
    for (int i = 1; i < N; i++) d[i] = 0;
  }
  void update(int x, int val) {
    for (; x < N; x += x & -x) d[x] += val;
  }
  int get(int x) {
    int res = 0;
    for (; x > 0; x -= x & -x) res += d[x];
    return res;
  }
} bit;
int n, q;
vector<pair<int, int> > adj[N];
int x[N], y[N], Time;
long long up[N], down[N];
pair<long long, int> h[N];
void readInput() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v, c;
    scanf("%d %d %d", &u, &v, &c);
    adj[u].push_back(make_pair(v, c));
    adj[v].push_back(make_pair(u, c));
  }
}
void dfs1(int u, int p) {
  down[u] = 0;
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    int c = e.second;
    if (v == p) continue;
    dfs1(v, u);
    down[u] = max(down[u], down[v] + c);
  }
}
void dfs2(int u, int p) {
  for (int t = 0; t < 2; t++) {
    reverse(adj[u].begin(), adj[u].end());
    long long maxVal = up[u];
    for (pair<int, int> e : adj[u]) {
      int v = e.first;
      int c = e.second;
      if (v == p) continue;
      up[v] = max(up[v], maxVal + c);
      maxVal = max(maxVal, down[v] + c);
    }
  }
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    if (v == p) continue;
    dfs2(v, u);
  }
}
void dfs3(int u, int p) {
  x[u] = ++Time;
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    if (v == p) continue;
    dfs3(v, u);
  }
  y[u] = Time;
}
void solve() {
  dfs1(1, 1);
  dfs2(1, 1);
  for (int i = 1; i <= n; i++) h[i] = make_pair(max(up[i], down[i]), i);
  sort(h + 1, h + 1 + n);
  dfs3(h[1].second, h[1].second);
  scanf("%d", &q);
  while (q--) {
    long long val;
    scanf("%I64d", &val);
    bit.reset();
    int l = 1, r = 1, res = 0;
    for (int i = 1; i <= n; i++) {
      while (h[l].first != h[i].first) {
        bit.update(x[h[l].second], -1);
        l++;
      }
      while (r <= n && h[r].first - h[i].first <= val) {
        bit.update(x[h[r].second], 1);
        r++;
      }
      res = max(res, bit.get(y[h[i].second]) - bit.get(x[h[i].second] - 1));
    }
    printf("%d\n", res);
  }
}
int main() {
  readInput();
  solve();
  return 0;
}
