#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100011;
struct edge {
  int x, y, w, nxt;
} E[MAXN << 1];
int head[MAXN], fa[MAXN], par[MAXN], siz[MAXN], ord[MAXN];
long long L, mxd[MAXN], mxd2[MAXN];
int n, m, q, tot;
inline bool cmp(int x, int y) { return mxd[x] > mxd[y]; }
inline void addedge(int x, int y, int w) {
  E[++tot] = (edge){x, y, w, head[x]};
  head[x] = tot;
}
inline void ChkTMx(int x, long long y) {
  if (y > mxd[x]) {
    mxd2[x] = mxd[x];
    mxd[x] = y;
  } else if (y > mxd2[x]) {
    mxd2[x] = y;
  }
}
inline void dfs1(int x, int f) {
  mxd[x] = mxd2[x] = 0;
  for (int i = head[x]; ~i; i = E[i].nxt) {
    int to = E[i].y;
    if (to != f) {
      dfs1(to, x);
      ChkTMx(x, mxd[to] + E[i].w);
    }
  }
}
inline void dfs2(int x, int f, long long d) {
  ChkTMx(x, d);
  for (int i = head[x]; ~i; i = E[i].nxt) {
    int to = E[i].y;
    if (to != f) {
      if (mxd[x] == E[i].w + mxd[to]) {
        dfs2(to, x, mxd2[x] + E[i].w);
      } else {
        dfs2(to, x, mxd[x] + E[i].w);
      }
    }
  }
}
inline void dfs3(int x, int f) {
  par[x] = f;
  for (int i = head[x]; ~i; i = E[i].nxt) {
    int to = E[i].y;
    if (to != f) {
      dfs3(to, x);
    }
  }
}
inline int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
inline void unite(int x, int y) {
  int fx = getfa(x), fy = getfa(y);
  if (fx == fy) return;
  if (siz[fx] <= siz[fy]) {
    fa[fx] = fy;
    siz[fy] += siz[fx];
  } else {
    fa[fy] = fx;
    siz[fx] += siz[fy];
  }
}
int main() {
  memset(head, -1, sizeof head);
  scanf("%d", &n);
  for (int i = 1, x, y, z; i < n; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    addedge(x, y, z);
    addedge(y, x, z);
  }
  dfs1(1, 0);
  dfs2(1, 0, 0);
  long long mnd = 1e18;
  int mid = 0;
  for (int i = 1; i <= n; ++i) {
    ord[i] = i;
    if (mxd[i] < mnd) {
      mnd = mxd[i];
      mid = i;
    }
  }
  dfs3(mid, 0);
  sort(ord + 1, ord + 1 + n, cmp);
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    scanf("%lld", &L);
    int pnt = 0;
    for (int j = 1; j <= n; ++j) {
      fa[j] = j;
      siz[j] = 1;
    }
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
      int now = ord[j];
      for (int k = head[now]; ~k; k = E[k].nxt) {
        int to = E[k].y;
        if (to != par[now]) {
          unite(now, to);
        }
      }
      while (pnt < j && mxd[ord[pnt + 1]] > mxd[now] + L) {
        ++pnt;
        --siz[getfa(ord[pnt])];
      }
      ans = max(ans, siz[getfa(now)]);
    }
    printf("%d\n", ans);
  }
  return 0;
}
