#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, T, l, f[N], d[N], L[N], R[N], par[N], len[N];
vector<pair<long long, long long> > a[N], ed;
bool vs[N], ver[N];
void dfs_down(long long x) {
  vs[x] = true;
  for (auto i : a[x]) {
    if (vs[i.first]) continue;
    dfs_down(i.first);
    f[x] = max(f[x], f[i.first] + i.second);
  }
}
void dfs_up(long long x) {
  vs[x] = true;
  vector<pair<long long, long long> > tmp;
  tmp.clear();
  tmp.push_back({0, 0});
  for (auto i : a[x]) {
    if (vs[i.first]) continue;
    tmp.push_back({i.first, i.second});
  }
  L[0] = 0, R[tmp.size()] = 0;
  for (long long i = 1; i < tmp.size(); i++)
    L[i] = max(L[i - 1], f[tmp[i].first] + tmp[i].second);
  for (long long i = tmp.size() - 1; i >= 1; i--)
    R[i] = max(R[i + 1], f[tmp[i].first] + tmp[i].second);
  for (long long i = 1; i < tmp.size(); i++) {
    d[tmp[i].first] = max({L[i - 1] + tmp[i].second, R[i + 1] + tmp[i].second});
    d[tmp[i].first] = max(d[tmp[i].first], d[x] + tmp[i].second);
  }
  for (auto i : a[x]) {
    if (vs[i.first]) continue;
    dfs_up(i.first);
  }
}
void in() {
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    a[u].push_back({v, w}), a[v].push_back({u, w});
  }
  dfs_down(1);
  memset(vs, false, sizeof(vs));
  dfs_up(1);
  for (long long i = 1; i <= n; i++) {
    len[i] = max(f[i], d[i]);
    ed.push_back({len[i], i});
  }
  sort(ed.rbegin(), ed.rend());
}
long long root(long long x) {
  if (par[x] < 0) return x;
  return par[x] = root(par[x]);
}
void Merge(long long u, long long v) {
  if ((u = root(u)) == (v = root(v))) return;
  if (par[u] > par[v]) swap(u, v);
  par[u] += par[v], par[v] = u;
}
void Remove(long long x) { par[root(x)]++; }
void process() {
  long long res = 0, low = 0;
  memset(par, -1, sizeof(par));
  memset(ver, 0, sizeof(ver));
  for (long long i = 0; i < ed.size(); i++) {
    long long x = ed[i].second, dai = ed[i].first;
    while (low < i && ed[low].first - dai > l) {
      ver[ed[low].second] = false;
      Remove(ed[low].second);
      low++;
    }
    ver[x] = true;
    for (auto j : a[x]) {
      if (ver[j.first]) Merge(x, j.first);
    }
    res = max(res, abs(par[root(x)]));
  }
  cout << res << '\n';
}
int main() {
  if (fopen("trash.inp", "r"))
    freopen("trash.inp", "r", stdin), freopen("trash.out", "w", stdout);
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  in();
  cin >> T;
  while (T--) {
    cin >> l;
    process();
  }
}
