#include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 20 | 1;
inline char gc() {
  static char ibuf[RLEN], *ib, *ob;
  (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
  return (ib == ob) ? EOF : *ib++;
}
inline int read() {
  char ch = gc();
  int res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline long long readll() {
  char ch = gc();
  long long res = 0;
  bool f = 1;
  while (!isdigit(ch)) f ^= ch == '-', ch = gc();
  while (isdigit(ch)) res = (res + (res << 2) << 1) + (ch ^ 48), ch = gc();
  return f ? res : -res;
}
inline int readstring(char *s) {
  int top = 0;
  char ch = gc();
  while (isspace(ch)) ch = gc();
  while (!isspace(ch) && ch != EOF) s[++top] = ch, ch = gc();
  return top;
}
template <class tp>
inline void chemx(tp &a, tp b) {
  a < b ? a = b : 0;
}
template <class tp>
inline void chemn(tp &a, tp b) {
  a > b ? a = b : 0;
}
const int N = 100005;
int fa[N], siz[N];
vector<pair<int, int> > e[N];
long long mxdis, dis[N], f[N];
int rt, n, id[N];
void dfs1(int u, int fa) {
  for (pair<int, int> &x : e[u])
    if (x.first != fa) {
      dis[x.first] = dis[u] + x.second;
      dfs1(x.first, u);
    }
}
void dfs2(int u) {
  for (pair<int, int> &x : e[u])
    if (x.first != fa[u]) {
      fa[x.first] = u, dfs2(x.first);
    }
}
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline void delet(int x) { siz[find(x)]--; }
inline void merge(int u, int v) {
  int f1 = find(u), f2 = find(v);
  if (f1 != f2) fa[f1] = f2, siz[f2] += siz[f1];
}
inline bool compf(int a, int b) { return f[a] > f[b]; }
inline void solve() {
  int ans = 0;
  for (int i = 1; i <= n; i++) siz[i] = 1, fa[i] = i;
  long long lim = readll();
  for (int l = 1, i = 1; i <= n; i++) {
    int u = id[i];
    while (f[id[l]] - f[u] > lim) delet(id[l++]);
    for (pair<int, int> &x : e[u])
      if (x.first != fa[u]) {
        merge(u, x.first);
      }
    chemx(ans, siz[u]);
  }
  cout << ans << '\n';
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read(), w = read();
    e[u].push_back(pair<int, int>(v, w)), e[v].push_back(pair<int, int>(u, w));
  }
  dfs1(1, 0);
  for (int i = 1; i <= n; i++)
    if (dis[i] > dis[rt]) rt = i;
  dis[rt] = 0;
  dfs1(rt, 0);
  for (int i = 1; i <= n; i++) {
    if (dis[i] > dis[rt]) rt = i;
    f[i] = dis[i];
  }
  dis[rt] = 0;
  dfs1(rt, 0);
  for (int i = 1; i <= n; i++) chemx(f[i], dis[i]);
  for (int i = 1; i <= n; i++)
    if (f[i] < f[rt]) rt = i;
  dfs2(rt);
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, compf);
  int q = read();
  while (q--) solve();
  return 0;
}
