#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smax(T &a, const U &b) {
  if (a < b) a = b;
}
char gchar() {
  static char tbuf1[1000], *tmp_st = tbuf1, *tmp_ed = tbuf1;
  if (tmp_st == tmp_ed) {
    int len = fread(tbuf1, 1, 1000, stdin);
    if (len == 0) return -1;
    tmp_ed = tbuf1 + len;
    tmp_st = tbuf1;
  }
  return *(tmp_st++);
}
inline bool gn(int &first) {
  char c, sg = 0;
  while (c = gchar(), (c > '9' || c < '0') && c != '-' && ~c)
    ;
  if (c == -1) return 0;
  for ((c == '-' ? sg = 1, c = gchar() : 0), first = 0; c >= '0' && c <= '9';
       c = gchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
  return 1;
}
inline bool gn(long long &first) {
  char c, sg = 0;
  while (c = gchar(), (c > '9' || c < '0') && c != '-' && ~c)
    ;
  if (c == -1) return 0;
  for ((c == '-' ? sg = 1, c = gchar() : 0), first = 0; c >= '0' && c <= '9';
       c = gchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
  return 1;
}
inline void print(int first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
vector<pair<int, int> > adj[100001];
long long mx[100001][2];
inline void insert(int u, long long first) {
  if (first > mx[u][1]) {
    mx[u][1] = first;
    if (mx[u][1] > mx[u][0]) swap(mx[u][0], mx[u][1]);
  }
}
inline void dfs(int u, int fa = 0) {
  for (pair<int, int> e : adj[u]) {
    int v = e.first, w = e.second;
    if (v != fa) {
      dfs(v, u);
      insert(u, mx[v][0] + w);
    }
  }
}
inline void rdfs(int u, int fa = 0, long long up = 0) {
  insert(u, up);
  for (pair<int, int> e : adj[u]) {
    int v = e.first, w = e.second;
    if (v != fa) {
      if (mx[u][0] == mx[v][0] + w)
        rdfs(v, u, mx[u][1] + w);
      else
        rdfs(v, u, mx[u][0] + w);
    }
  }
}
int pa[100001];
inline void Dfs(int u, int fa = 0) {
  for (pair<int, int> e : adj[u]) {
    int v = e.first;
    if (v != fa) {
      Dfs(v, u);
      pa[v] = u;
    }
  }
}
int root[100001], sz[100001], id[100001];
inline int find(int u) { return root[u] == u ? u : root[u] = find(root[u]); }
int main() {
  int n;
  gn(n);
  for (int i = 1, u, v, w; i < n; i++) {
    gn(u), gn(v), gn(w);
    adj[u].push_back(pair<int, int>(v, w));
    adj[v].push_back(pair<int, int>(u, w));
  }
  dfs(1);
  rdfs(1);
  for (int i = 1; i <= n; i++) id[i] = i;
  sort(id + 1, id + n + 1, [](int u, int v) { return *mx[u] < *mx[v]; });
  Dfs(id[1]);
  int m;
  gn(m);
  while (m--) {
    long long L;
    gn(L);
    int ans = 0;
    for (int i = 1; i <= n; i++) root[i] = i, sz[i] = 0;
    for (int st = n, ed = n; st; st--) {
      while (*mx[id[ed]] - *mx[id[st]] > L) sz[find(id[ed--])]--;
      smax(ans, ++sz[id[st]]);
      root[id[st]] = pa[id[st]];
      sz[pa[id[st]]] += sz[id[st]];
    }
    print(ans);
    putchar('\n');
  }
}
