Problem: Drazil and Varda are the earthworm couple. They want to find a good place to bring up their children. They found a good ground containing nature hole. The hole contains many rooms, some pairs of rooms are connected by small tunnels such that earthworm can move between them.

Let's consider rooms and small tunnels as the vertices and edges in a graph. This graph is a tree. In the other words, any pair of vertices has an unique path between them.

Each room that is leaf in the graph is connected with a ground by a vertical tunnel. Here, leaf is a vertex that has only one outgoing edge in the graph.

Each room is large enough only to fit one earthworm living in it. Earthworm can't live in a tunnel.

Drazil and Varda have a plan to educate their children. They want all their children to do morning exercises immediately after getting up!

When the morning is coming, all earthworm children get up in the same time, then each of them chooses the farthest path to the ground for gathering with others (these children are lazy, so they all want to do exercises as late as possible).

Drazil and Varda want the difference between the time first earthworm child arrives outside and the time the last earthworm child arrives outside to be not larger than l (otherwise children will spread around the ground and it will be hard to keep them exercising together).

Also, The rooms that are occupied by their children should form a connected set. In the other words, for any two rooms that are occupied with earthworm children, all rooms that lie on the path between them should be occupied with earthworm children too.

How many children Drazil and Varda may have at most in order to satisfy all conditions above? Drazil and Varda want to know the answer for many different choices of l.

(Drazil and Varda don't live in the hole with their children)

Input

The first line contains one integer n denoting how many rooms there are in the hole (2 ≤ n ≤ 105).

Then there are n - 1 lines following. Each of these lines contains three integers x, y, v (1 ≤ x, y ≤ n, 1 ≤ v ≤ 106) denoting there is a small tunnel between room x and room y that takes time v to pass. 

Suppose that the time for an earthworm to get out to the ground from any leaf room is the same.

The next line contains an integer q (1 ≤ q ≤ 50), denoting the number of different value of l you need to process.

The last line contains q numbers, each number denoting a value of l (1 ≤ l ≤ 1011).

Output

You should print q lines. Each line should contain one integer denoting the answer for a corresponding value of l.

Examples

Input

5
1 2 3
2 3 4
4 5 3
3 4 2
5
1 2 3 4 5


Output

1
3
3
3
5


Input

12
5 9 3
2 1 7
11 7 2
6 5 5
2 5 3
6 7 2
1 4 4
8 5 7
1 3 8
11 12 3
10 8 2
10
13 14 14 13 13 4 6 7 2 1


Output

10
10
10
10
10
3
3
5
2
1

Note

For the first sample the hole looks like the following. Rooms 1 and 5 are leaves, so they contain a vertical tunnel connecting them to the ground. The lengths of farthest path from rooms 1 – 5 to the ground are 12, 9, 7, 9, 12 respectively. 

If l = 1, we may only choose any single room. 

If l = 2..4, we may choose rooms 2, 3, and 4 as the answer. 

If l = 5, we may choose all rooms.

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const int N = 100007;
vector<pair<int, int> > edge[N];
long long far_up[N], far_down[N], far[N];
void go_down(int x, int fa) {
  far_down[x] = 0;
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) continue;
    go_down(it->first, x);
    far_down[x] = max(far_down[x], far_down[it->first] + it->second);
  }
}
void go_up(int x, int fa) {
  far[x] = max(far_up[x], far_down[x]);
  for (int i = 0; i < edge[x].size(); i++) {
    if (edge[x][i].first == fa) {
      continue;
    }
    far_up[edge[x][i].first] = far_up[x] + edge[x][i].second;
  }
  long long current = 0;
  for (int i = 0; i < edge[x].size(); i++) {
    if (edge[x][i].first == fa) continue;
    far_up[edge[x][i].first] =
        max(far_up[edge[x][i].first], current + edge[x][i].second);
    current = max(current, far_down[edge[x][i].first] + edge[x][i].second);
  }
  current = 0;
  for (int i = edge[x].size() - 1; i >= 0; --i) {
    if (edge[x][i].first == fa) continue;
    far_up[edge[x][i].first] =
        max(far_up[edge[x][i].first], current + edge[x][i].second);
    current = max(current, far_down[edge[x][i].first] + edge[x][i].second);
  }
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) continue;
    go_up(it->first, x);
  }
}
long long dis[N];
int last_time = 0;
int inner[N], outter[N], which[N];
void dfs(int x, int fa, long long d) {
  which[last_time] = x;
  inner[x] = last_time++;
  dis[x] = d;
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) continue;
    dfs(it->first, x, d + it->second);
  }
  outter[x] = last_time - 1;
}
const int MAXN = 2222222;
struct Node2 {
  int l, r, cl, cr, val;
  Node2(int tl, int tr, int tcl, int tcr, int tval = 0)
      : l(tl), r(tr), cl(tcl), cr(tcr), val(tval) {}
  Node2() {}
} tree[MAXN];
int last;
int getNode() { return last++; }
int makeNode(int left, int right, int cl, int cr, int x) {
  tree[x] = Node2(left, right, cl, cr);
  tree[x].val = tree[cl].val + tree[cr].val;
  return x;
}
int build(int left, int right, int val, int x) {
  tree[x].l = left;
  tree[x].r = right;
  if (left == right) {
    tree[x].val = val;
    return x;
  }
  int mid = (left + right) >> 1;
  tree[x].cl = build(left, mid, val, getNode());
  tree[x].cr = build(mid + 1, right, val, getNode());
  tree[x].val = tree[tree[x].cl].val + tree[tree[x].cr].val;
  return x;
}
int add(int pos, int val, int x) {
  if (tree[x].l == tree[x].r)
    return build(tree[x].l, tree[x].r, tree[x].val + val, getNode());
  int mid = tree[tree[x].cl].r;
  if (pos <= mid)
    return makeNode(tree[x].l, tree[x].r, add(pos, val, tree[x].cl), tree[x].cr,
                    getNode());
  return makeNode(tree[x].l, tree[x].r, tree[x].cl, add(pos, val, tree[x].cr),
                  getNode());
}
int root[MAXN];
bool cmp(const pair<long long, vector<pair<int, int> >::iterator>& a,
         const pair<long long, vector<pair<int, int> >::iterator>& b) {
  return a.first > b.first;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y, v;
    scanf("%d%d%d", &x, &y, &v);
    --x;
    --y;
    edge[x].push_back(make_pair(y, v));
    edge[y].push_back(make_pair(x, v));
  }
  go_down(0, -1);
  go_up(0, -1);
  long long max_d = 0x3F3F3F3F3F3F3F3FLL;
  for (int i = 0; i < n; i++) max_d = min(max_d, far[i]);
  vector<int> center;
  for (int i = 0; i < n; i++)
    if (max_d == far[i]) center.push_back(i);
  assert(center.size() <= 2);
  int real_center = center[0];
  if (center.size() == 2) {
    for (__typeof(edge[center[0]].begin()) it = edge[center[0]].begin();
         it != edge[center[0]].end(); it++)
      if (it->first == center[1]) {
        edge[center[0]].erase(it);
        break;
      }
    for (__typeof(edge[center[1]].begin()) it = edge[center[1]].begin();
         it != edge[center[1]].end(); it++)
      if (it->first == center[0]) {
        edge[center[1]].erase(it);
        break;
      }
    edge[n].push_back(make_pair(center[0], 0));
    edge[n].push_back(make_pair(center[1], 0));
    edge[center[0]].push_back(make_pair(n, 0));
    edge[center[1]].push_back(make_pair(n, 0));
    real_center = n;
    ++n;
  }
  go_down(real_center, -1);
  vector<pair<long long, vector<pair<int, int> >::iterator> > down_edges;
  for (__typeof(edge[real_center].begin()) it = edge[real_center].begin();
       it != edge[real_center].end(); it++) {
    down_edges.push_back(make_pair(far_down[it->first] + it->second, it));
  }
  sort(down_edges.begin(), down_edges.end(), cmp);
  if (down_edges.size() >= 2 && down_edges[0].first != down_edges[1].first) {
    down_edges[0].second->second -= (down_edges[0].first - down_edges[1].first);
  }
  dfs(real_center, -1, 0);
  vector<long long> dists(n);
  for (int i = 0; i < n; i++) dists[i] = dis[i];
  sort(dists.begin(), dists.end());
  dists.erase(unique(dists.begin(), dists.end()), dists.end());
  int total = dists.size() - 1;
  int cur = build(0, total, 0, getNode());
  root[0] = cur;
  for (int i = 0; i < n; i++) {
    root[i + 1] = add(
        lower_bound(dists.begin(), dists.end(), dis[which[i]]) - dists.begin(),
        1, cur);
    cur = root[i + 1];
  }
  int q;
  cin >> q;
  while (q--) {
    long long d;
    cin >> d;
    int res = 0;
    for (int i = 0; i < n; ++i) {
      int b = inner[i];
      int e = outter[i] + 1;
      long long max_dis = dis[i] + d;
      int r =
          upper_bound(dists.begin(), dists.end(), max_dis) - dists.begin() - 1;
      int ans = 0;
      int cury = root[e], curx = root[b];
      while (true) {
        int have = tree[cury].val - tree[curx].val;
        if (r >= tree[cury].r) {
          ans += have;
          break;
        }
        if (r > tree[tree[cury].cl].r) {
          ans += tree[tree[cury].cl].val - tree[tree[curx].cl].val;
          curx = tree[curx].cr;
          cury = tree[cury].cr;
        } else {
          curx = tree[curx].cl;
          cury = tree[cury].cl;
        }
      }
      if (center.size() == 2 && i == n - 1) {
        --ans;
      }
      res = max(res, ans);
    }
    cout << res << endl;
  }
  return 0;
}