#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, q, rt, tot, ans, ver[N << 1], edge[N << 1], nxt[N << 1], head[N], f[N],
    sz[N];
bool used[N];
long long d[N];
struct node {
  int id;
  long long x;
} a[N];
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  return f ? x : -x;
}
bool cmp(const node &x, const node &y) { return x.x < y.x; }
void add(int x, int y, int z) {
  ver[++tot] = y, edge[tot] = z, nxt[tot] = head[x], head[x] = tot;
}
void dfs(int x, int p) {
  a[x].x = max(a[x].x, d[x]);
  if (d[x] > d[rt]) rt = x;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y == p) continue;
    d[y] = d[x] + edge[i], dfs(y, x);
  }
}
int getf(int x) { return x == f[x] ? x : f[x] = getf(f[x]); }
int main() {
  n = read(), a[n].id = n;
  for (int i = 1; i < n; i++) {
    int x = read(), y = read(), z = read();
    add(x, y, z), add(y, x, z), a[i].id = i;
  }
  dfs(1, 0), d[rt] = 0, dfs(rt, 0), d[rt] = 0, dfs(rt, 0),
             sort(a + 1, a + n + 1, cmp), q = read();
  while (q--) {
    for (int i = 1; i <= n; i++) f[i] = i, sz[i] = 1, used[i] = 0;
    ans = 1;
    long long x = read();
    for (int i = n, j = n; i; i--) {
      while (j > i && a[j].x > a[i].x + x)
        sz[getf(a[j].id)]--, used[a[j].id] = 0, j--;
      used[a[i].id] = 1;
      for (int k = head[a[i].id]; k; k = nxt[k])
        if (used[ver[k]]) {
          int y = getf(a[i].id), z = getf(ver[k]);
          if (y != z) sz[y] += sz[z], f[z] = y;
        }
      ans = max(ans, sz[getf(a[i].id)]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
