#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, rad, q, p[N];
long long distmax[N], djos[N], l;
vector<pair<int, int> > v[N];
void ca(int nod, int p) {
  for (vector<pair<int, int> >::iterator it = v[nod].begin();
       it != v[nod].end(); ++it)
    if (it->first != p) {
      ca(it->first, nod);
      djos[nod] = max(djos[nod], djos[it->first] + it->second);
    }
}
void calc(int nod, int p, long long sus) {
  vector<pair<int, int> >::iterator it;
  long long smax1 = 0, smax2 = 0;
  distmax[nod] = max(sus, djos[nod]);
  for (it = v[nod].begin(); it != v[nod].end(); ++it)
    if (it->first != p) {
      if (djos[it->first] + it->second > smax1) {
        smax2 = smax1;
        smax1 = djos[it->first] + it->second;
      } else if (djos[it->first] + it->second > smax2)
        smax2 = djos[it->first] + it->second;
    }
  for (it = v[nod].begin(); it != v[nod].end(); ++it)
    if (it->first != p) {
      long long ne = sus + it->second;
      if (djos[it->first] + it->second == smax1)
        ne = max(ne, smax2 + it->second);
      else
        ne = max(ne, smax1 + it->second);
      calc(it->first, nod, ne);
    }
}
int cs[N], cd[N], nr, aib[N];
void df(int nod, int p) {
  cs[nod] = ++nr;
  for (vector<pair<int, int> >::iterator it = v[nod].begin();
       it != v[nod].end(); ++it)
    if (it->first != p) df(it->first, nod);
  cd[nod] = nr;
}
void update(int poz) {
  for (; poz <= nr; poz += (poz & (-poz))) aib[poz]++;
}
int sum(int poz) {
  int r = 0;
  for (; poz; poz -= (poz & (-poz))) r += aib[poz];
  return r;
}
int query(int a, int b) { return sum(b) - sum(a - 1); }
void sol() {
  int i, j = 1, rez = 0;
  memset(aib, 0, sizeof(aib));
  for (i = 1; i <= n; ++i) {
    while (j <= n && distmax[p[i]] + l >= distmax[p[j]]) {
      update(cs[p[j]]);
      ++j;
    }
    rez = max(rez, query(cs[p[i]], cd[p[i]]));
  }
  cout << rez << "\n";
}
bool cmp(int a, int b) { return distmax[a] < distmax[b]; }
int main() {
  int i;
  cin >> n;
  for (i = 1; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a].push_back(pair<int, int>(b, c));
    v[b].push_back(pair<int, int>(a, c));
  }
  ca(1, 0);
  calc(1, 0, 0);
  long long dmin = 1LL << 60;
  for (i = 1; i <= n; ++i) {
    p[i] = i;
    if (distmax[i] < dmin) {
      dmin = distmax[i];
      rad = i;
    }
  }
  df(rad, 0);
  sort(p + 1, p + n + 1, cmp);
  cin >> q;
  for (i = 1; i <= q; ++i) {
    cin >> l;
    sol();
  }
  return 0;
}
