#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 100007;
vector<pair<int, int> > edge[N];
long long far_up[N], far_down[N], far[N];
void go_down(int x, int fa) {
  far_down[x] = 0;
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) continue;
    go_down(it->first, x);
    far_down[x] = max(far_down[x], far_down[it->first] + it->second);
  }
}
void go_up(int x, int fa) {
  far[x] = max(far_up[x], far_down[x]);
  for (int i = 0; i < edge[x].size(); i++) {
    if (edge[x][i].first == fa) {
      continue;
    }
    far_up[edge[x][i].first] = far_up[x] + edge[x][i].second;
  }
  long long current = 0;
  for (int i = 0; i < edge[x].size(); i++) {
    if (edge[x][i].first == fa) continue;
    far_up[edge[x][i].first] =
        max(far_up[edge[x][i].first], current + edge[x][i].second);
    current = max(current, far_down[edge[x][i].first] + edge[x][i].second);
  }
  current = 0;
  for (int i = edge[x].size() - 1; i >= 0; --i) {
    if (edge[x][i].first == fa) continue;
    far_up[edge[x][i].first] =
        max(far_up[edge[x][i].first], current + edge[x][i].second);
    current = max(current, far_down[edge[x][i].first] + edge[x][i].second);
  }
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) continue;
    go_up(it->first, x);
  }
}
long long dis[N];
int last_time = 0;
int inner[N], outter[N], which[N];
void dfs(int x, int fa, long long d) {
  which[last_time] = x;
  inner[x] = last_time++;
  dis[x] = d;
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) continue;
    dfs(it->first, x, d + it->second);
  }
  outter[x] = last_time - 1;
}
const int MAXN = 2222222;
struct Node2 {
  int l, r, cl, cr, val;
  Node2(int tl, int tr, int tcl, int tcr, int tval = 0)
      : l(tl), r(tr), cl(tcl), cr(tcr), val(tval) {}
  Node2() {}
} tree[MAXN];
int last;
int getNode() { return last++; }
int makeNode(int left, int right, int cl, int cr, int x) {
  tree[x] = Node2(left, right, cl, cr);
  tree[x].val = tree[cl].val + tree[cr].val;
  return x;
}
int build(int left, int right, int val, int x) {
  tree[x].l = left;
  tree[x].r = right;
  if (left == right) {
    tree[x].val = val;
    return x;
  }
  int mid = (left + right) >> 1;
  tree[x].cl = build(left, mid, val, getNode());
  tree[x].cr = build(mid + 1, right, val, getNode());
  tree[x].val = tree[tree[x].cl].val + tree[tree[x].cr].val;
  return x;
}
int add(int pos, int val, int x) {
  if (tree[x].l == tree[x].r)
    return build(tree[x].l, tree[x].r, tree[x].val + val, getNode());
  int mid = tree[tree[x].cl].r;
  if (pos <= mid)
    return makeNode(tree[x].l, tree[x].r, add(pos, val, tree[x].cl), tree[x].cr,
                    getNode());
  return makeNode(tree[x].l, tree[x].r, tree[x].cl, add(pos, val, tree[x].cr),
                  getNode());
}
int root[MAXN];
bool cmp(const pair<long long, vector<pair<int, int> >::iterator>& a,
         const pair<long long, vector<pair<int, int> >::iterator>& b) {
  return a.first > b.first;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y, v;
    scanf("%d%d%d", &x, &y, &v);
    --x;
    --y;
    edge[x].push_back(make_pair(y, v));
    edge[y].push_back(make_pair(x, v));
  }
  go_down(0, -1);
  go_up(0, -1);
  long long max_d = 0x3F3F3F3F3F3F3F3FLL;
  for (int i = 0; i < n; i++) max_d = min(max_d, far[i]);
  vector<int> center;
  for (int i = 0; i < n; i++)
    if (max_d == far[i]) center.push_back(i);
  assert(center.size() <= 2);
  int real_center = center[0];
  if (center.size() == 2) {
    for (__typeof(edge[center[0]].begin()) it = edge[center[0]].begin();
         it != edge[center[0]].end(); it++)
      if (it->first == center[1]) {
        edge[center[0]].erase(it);
        break;
      }
    for (__typeof(edge[center[1]].begin()) it = edge[center[1]].begin();
         it != edge[center[1]].end(); it++)
      if (it->first == center[0]) {
        edge[center[1]].erase(it);
        break;
      }
    edge[n].push_back(make_pair(center[0], 0));
    edge[n].push_back(make_pair(center[1], 0));
    edge[center[0]].push_back(make_pair(n, 0));
    edge[center[1]].push_back(make_pair(n, 0));
    real_center = n;
    ++n;
  }
  go_down(real_center, -1);
  vector<pair<long long, vector<pair<int, int> >::iterator> > down_edges;
  for (__typeof(edge[real_center].begin()) it = edge[real_center].begin();
       it != edge[real_center].end(); it++) {
    down_edges.push_back(make_pair(far_down[it->first] + it->second, it));
  }
  sort(down_edges.begin(), down_edges.end(), cmp);
  if (down_edges.size() >= 2 && down_edges[0].first != down_edges[1].first) {
    down_edges[0].second->second -= (down_edges[0].first - down_edges[1].first);
  }
  dfs(real_center, -1, 0);
  vector<long long> dists(n);
  for (int i = 0; i < n; i++) dists[i] = dis[i];
  sort(dists.begin(), dists.end());
  dists.erase(unique(dists.begin(), dists.end()), dists.end());
  int total = dists.size() - 1;
  int cur = build(0, total, 0, getNode());
  root[0] = cur;
  for (int i = 0; i < n; i++) {
    root[i + 1] = add(
        lower_bound(dists.begin(), dists.end(), dis[which[i]]) - dists.begin(),
        1, cur);
    cur = root[i + 1];
  }
  int q;
  cin >> q;
  while (q--) {
    long long d;
    cin >> d;
    int res = 0;
    for (int i = 0; i < n; ++i) {
      int b = inner[i];
      int e = outter[i] + 1;
      long long max_dis = dis[i] + d;
      int r =
          upper_bound(dists.begin(), dists.end(), max_dis) - dists.begin() - 1;
      int ans = 0;
      int cury = root[e], curx = root[b];
      while (true) {
        int have = tree[cury].val - tree[curx].val;
        if (r >= tree[cury].r) {
          ans += have;
          break;
        }
        if (r > tree[tree[cury].cl].r) {
          ans += tree[tree[cury].cl].val - tree[tree[curx].cl].val;
          curx = tree[curx].cr;
          cury = tree[cury].cr;
        } else {
          curx = tree[curx].cl;
          cury = tree[cury].cl;
        }
      }
      if (center.size() == 2 && i == n - 1) {
        --ans;
      }
      res = max(res, ans);
    }
    cout << res << endl;
  }
  return 0;
}
