#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 101010;
long long far[N];
long long dist[3][N];
vector<pair<int, int> > g[N];
vector<pair<long long, int> > evs[N];
int answer[N];
void dfs(int u, int p, int id) {
  for (__typeof((g[u]).begin()) it = (g[u]).begin(); it != (g[u]).end(); it++) {
    int v = it->first;
    int c = it->second;
    if (v != p) {
      dist[id][v] = dist[id][u] + c;
      dfs(v, u, id);
    }
  }
}
int who[N];
int tin[N], tout[N], ptr;
void go(int u, int p) {
  tin[u] = ++ptr;
  who[ptr] = u;
  for (__typeof((g[u]).begin()) it = (g[u]).begin(); it != (g[u]).end(); it++) {
    int v = it->first;
    if (v != p) {
      go(v, u);
    }
  }
  tout[u] = ptr;
}
vector<long long> vals;
int f[N];
void add(long long v) {
  int x = lower_bound((vals).begin(), (vals).end(), v) - vals.begin() + 10;
  while (x < N) {
    ++f[x];
    x += x & -x;
  }
}
int get(long long v) {
  int x = upper_bound((vals).begin(), (vals).end(), v) - vals.begin() - 1 + 10;
  int s = 0;
  while (x > 0) {
    s += f[x];
    x -= x & -x;
  }
  return s;
}
int main() {
  int n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read(), c = read();
    g[u].push_back(pair<int, int>(v, c));
    g[v].push_back(pair<int, int>(u, c));
  }
  dfs(1, 0, 0);
  int d1 = 1;
  for (int i = 1; i <= n; i++)
    if (dist[0][i] > dist[0][d1]) d1 = i;
  dfs(d1, 0, 1);
  int d2 = 1;
  for (int i = 1; i <= n; i++)
    if (dist[1][i] > dist[1][d2]) d2 = i;
  dfs(d2, 0, 2);
  int root = 1;
  for (int i = 1; i <= n; i++) {
    far[i] = max(dist[1][i], dist[2][i]);
    vals.push_back(far[i]);
    if (far[i] < far[root]) {
      root = i;
    }
  }
  sort((vals).begin(), (vals).end());
  vals.erase(unique((vals).begin(), (vals).end()), vals.end());
  go(root, 0);
  int m = read();
  for (int tt = 0; tt < m; tt++) {
    long long len;
    cin >> len;
    for (int i = 0; i < N; i++) evs[i].clear();
    for (int i = 1; i <= n; i++) {
      evs[tout[i]].push_back(make_pair(far[i] + len, +i));
      evs[tin[i] - 1].push_back(make_pair(far[i] + len, -i));
    }
    for (int i = 0; i < N; i++) f[i] = answer[i] = 0;
    for (int i = 1; i <= n; i++) {
      add(far[who[i]]);
      for (__typeof((evs[i]).begin()) it = (evs[i]).begin();
           it != (evs[i]).end(); it++) {
        long long upto = it->first;
        int id = it->second;
        if (id > 0) {
          answer[id] += get(upto);
        } else {
          answer[-id] -= get(upto);
        }
      }
    }
    int maxsz = 0;
    for (int i = 1; i <= n; i++) {
      umax(maxsz, answer[i]);
    }
    printf("%d\n", maxsz);
  }
  return 0;
}
