#include <bits/stdc++.h>
using namespace std;
const int NN = 100000 + 117;
const int MM = 10000 + 117;
int read() {
  int fl = 1, x;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    fl = -1;
    c = getchar();
  }
  for (x = 0; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  return x * fl;
}
void open() { freopen("a.in", "r", stdin); }
void close() {
  fclose(stdin);
  fclose(stdout);
}
int m, n;
struct edge {
  int to, len;
  edge(int t = 0, int l = 0) { to = t, len = l; }
};
vector<edge> p[NN] = {};
long long dep[NN] = {};
long long v[NN] = {};
int f[NN] = {};
void dfs(int x, int fa) {
  f[x] = fa;
  for (int i = 0; i < p[x].size(); ++i) {
    int cur = p[x][i].to;
    if (cur != fa) {
      dep[cur] = dep[x] + p[x][i].len;
      dfs(cur, x);
    }
  }
}
long long lim;
int ord[NN] = {};
int fa[NN] = {};
int siz[NN] = {};
int getfa(int x) { return x == fa[x] ? x : fa[x] = getfa(fa[x]); }
bool link(int x, int y) {
  if (getfa(x) == getfa(y)) return false;
  siz[fa[y]] += siz[fa[x]];
  fa[fa[x]] = fa[y];
  return true;
}
bool cmp(int a, int b) { return v[a] > v[b]; }
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int x = read(), y = read(), v = read();
    p[x].push_back(edge(y, v));
    p[y].push_back(edge(x, v));
  }
  int rt = 1;
  for (int ti = 1; ti <= 3; ++ti) {
    dep[rt] = 0;
    dfs(rt, 0);
    for (int i = 1; i <= n; ++i) {
      if (dep[i] > dep[rt]) rt = i;
      v[i] = max(v[i], dep[i]);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (v[rt] > v[i]) rt = i;
  }
  dfs(rt, 0);
  int q = read();
  for (int i = 1; i <= n; ++i) ord[i] = i;
  sort(ord + 1, ord + 1 + n, cmp);
  for (int ti = 1; ti <= q; ++ti) {
    scanf("%I64d", &lim);
    for (int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1;
    int pos = 1;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      int x = ord[i];
      for (int j = 0; j < p[x].size(); ++j) {
        int cur = p[x][j].to;
        if (cur != f[x]) {
          link(x, cur);
        }
      }
      while (v[ord[pos]] > v[x] + lim) {
        getfa(ord[pos]);
        siz[fa[ord[pos]]]--;
        pos++;
      }
      ans = max(ans, siz[getfa(x)]);
    }
    printf("%d\n", ans);
  }
  close();
  return 0;
}
