Problem: The biggest gold mine in Berland consists of n caves, connected by n - 1 transitions. The entrance to the mine leads to the cave number 1, it is possible to go from it to any remaining cave of the mine by moving along the transitions. 

The mine is being developed by the InMine Inc., k miners work for it. Each day the corporation sorts miners into caves so that each cave has at most one miner working there. 

For each cave we know the height of its ceiling hi in meters, and for each miner we know his height sj, also in meters. If a miner's height doesn't exceed the height of the cave ceiling where he is, then he can stand there comfortably, otherwise, he has to stoop and that makes him unhappy.

Unfortunately, miners typically go on strike in Berland, so InMine makes all the possible effort to make miners happy about their work conditions. To ensure that no miner goes on strike, you need make sure that no miner has to stoop at any moment on his way from the entrance to the mine to his cave (in particular, he must be able to stand comfortably in the cave where he works). 

To reach this goal, you can choose exactly one cave and increase the height of its ceiling by several meters. However enlarging a cave is an expensive and complex procedure. That's why InMine Inc. asks you either to determine the minimum number of meters you should raise the ceiling of some cave so that it is be possible to sort the miners into the caves and keep all miners happy with their working conditions or to determine that it is impossible to achieve by raising ceiling in exactly one cave.

Input

The first line contains integer n (1 ≤ n ≤ 5·105) — the number of caves in the mine.

Then follows a line consisting of n positive integers h1, h2, ..., hn (1 ≤ hi ≤ 109), where hi is the height of the ceiling in the i-th cave.

Next n - 1 lines contain the descriptions of transitions between the caves. Each line has the form ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi), where ai and bi are the numbers of the caves connected by a path.

The next line contains integer k (1 ≤ k ≤ n).

The last line contains k integers s1, s2, ..., sk (1 ≤ sj ≤ 109), where sj is the j-th miner's height.

Output

In the single line print the minimum number of meters that you need to raise the ceiling by in some cave so that all miners could be sorted into caves and be happy about the work conditions. If it is impossible to do, print  - 1. If it is initially possible and there's no need to raise any ceiling, print 0. 

Examples

Input

6
5 8 4 6 3 12
1 2
1 3
4 2
2 5
6 3
6
7 4 2 5 3 11


Output

6


Input

7
10 14 7 12 4 50 1
1 2
2 3
2 4
5 1
6 5
1 7
6
7 3 4 8 8 10


Output

0


Input

3
4 2 8
1 2
1 3
2
17 15


Output

-1

Note

In the first sample test we should increase ceiling height in the first cave from 5 to 11. After that we can distribute miners as following (first goes index of a miner, then index of a cave): <image>.

In the second sample test there is no need to do anything since it is already possible to distribute miners as following: <image>.

In the third sample test it is impossible.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 500500, M = 1001000, oo = 1000000000;
int i, j, k, n, m, ch, nls, x, y, nn, ma, ans;
int a[M], b[M], s[M], Ls[M], dp[M], f[N][22], ST[N][22], sz[M], fa[M];
struct edge {
  int s, n;
};
void R(int &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int min(const int &x, const int &y) {
  if (x < y) return x;
  return y;
}
struct tree {
  int mi, ad;
} T[M << 2];
struct tree_edge {
  int i, j, k, En;
  int h[N];
  edge E[M];
  void add(int x, int y) {
    E[++En].s = y;
    E[En].n = h[x];
    h[x] = En;
  }
} A, B;
int get_fa(int x) {
  if (x == 1) return 0;
  int k = dp[x], v = a[x];
  for (j = nn; j >= 0; j--) {
    if (k <= (1 << j)) continue;
    if (a[ST[x][j]] > v) x = f[x][j], k -= 1 << j;
  }
  if (a[ST[x][0]] <= v) return ST[x][0];
  return 0;
}
int get_min(int x) {
  int k = dp[x], mi = oo;
  for (j = nn; j >= 0; j--) {
    if (k <= (1 << j)) continue;
    mi = min(mi, a[ST[x][j]]);
    x = f[x][j];
    k -= 1 << j;
  }
  return mi;
}
void dfs(int x, int F) {
  dp[x] = dp[F] + 1;
  for (int j = 1; j <= nn; j++) {
    if (dp[x] <= (1 << j)) break;
    if (a[ST[x][j - 1]] < a[ST[f[x][j - 1]][j - 1]])
      ST[x][j] = ST[x][j - 1];
    else
      ST[x][j] = ST[f[x][j - 1]][j - 1];
    f[x][j] = f[f[x][j - 1]][j - 1];
  }
  for (int k = A.h[x]; k; k = A.E[k].n)
    if (A.E[k].s != F) {
      int y = A.E[k].s;
      ST[y][0] = x;
      f[y][0] = x;
      dfs(y, x);
    }
}
void get_sz(int x) {
  sz[x] = 1;
  for (int k = B.h[x]; k; k = B.E[k].n) {
    get_sz(B.E[k].s);
    sz[x] += sz[B.E[k].s];
  }
}
int find(int x) {
  int l = 1, r = nls, mid;
  while (l < r) {
    mid = (l + r) >> 1;
    if (Ls[mid] == x) return mid;
    if (Ls[mid] < x)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return l;
}
void down(int k) {
  if (T[k].ad) {
    T[k << 1].ad += T[k].ad;
    T[k << 1 | 1].ad += T[k].ad;
    T[k << 1].mi += T[k].ad;
    T[k << 1 | 1].mi += T[k].ad;
    T[k].ad = 0;
  }
}
void T_build(int L, int R, int k) {
  if (L == R) {
    T[k].mi = s[L];
    return;
  }
  int mid = (L + R) >> 1;
  T_build(L, mid, k << 1);
  T_build(mid + 1, R, k << 1 | 1);
  T[k].mi = min(T[k << 1].mi, T[k << 1 | 1].mi);
}
void T_add(int L, int R, int l, int r, int ad, int k) {
  if (l > r) return;
  if (L == l && R == r) {
    T[k].ad += ad;
    T[k].mi += ad;
    return;
  }
  down(k);
  int mid = (L + R) >> 1;
  if (r <= mid)
    T_add(L, mid, l, r, ad, k << 1);
  else {
    if (l > mid)
      T_add(mid + 1, R, l, r, ad, k << 1 | 1);
    else
      T_add(L, mid, l, mid, ad, k << 1),
          T_add(mid + 1, R, mid + 1, r, ad, k << 1 | 1);
  }
  T[k].mi = min(T[k << 1].mi, T[k << 1 | 1].mi);
}
int main() {
  R(n);
  ans = oo;
  while ((1 << nn) < n) nn++;
  for (i = 1; i <= n; i++) {
    R(a[i]);
    Ls[++nls] = a[i];
  }
  for (i = 1; i < n; i++) {
    R(x);
    R(y);
    A.add(x, y);
    A.add(y, x);
  }
  R(m);
  for (i = 1; i <= m; i++) {
    R(b[i]);
    Ls[++nls] = b[i];
  }
  if (m > n) return puts("-1"), 0;
  sort(Ls + 1, Ls + nls + 1);
  int tmp = nls;
  nls = 0;
  Ls[tmp + 1] = -1;
  for (i = 1; i <= tmp; i++)
    if (Ls[i] != Ls[i + 1]) Ls[++nls] = Ls[i];
  for (i = 1; i <= n; i++) a[i] = find(a[i]);
  for (i = 1; i <= m; i++) b[i] = find(b[i]);
  dfs(1, 0);
  for (i = 1; i <= n; i++) {
    fa[i] = get_fa(i);
    B.add(fa[i], i);
  }
  get_sz(0);
  for (k = B.h[0]; k; k = B.E[k].n) s[a[B.E[k].s]] += sz[B.E[k].s];
  for (i = 1; i <= m; i++) s[b[i]]--;
  for (i = nls; i; i--) s[i] += s[i + 1];
  for (i = nls; i; i--)
    if (s[i] < 0) break;
  if (!i) return puts("0"), 0;
  ma = i;
  T_build(1, nls, 1);
  for (k = B.h[0]; k; k = B.E[k].n) {
    int x = B.E[k].s;
    if (a[x] >= ma) continue;
    int t = get_min(x);
    if (t < ma) continue;
    if (Ls[ma] - Ls[a[x]] >= ans) continue;
    for (int kk = B.h[x]; kk; kk = B.E[kk].n) {
      int y = B.E[kk].s;
      if (a[y] < ma) {
        if (a[x] < a[y]) T_add(1, nls, a[x] + 1, a[y], sz[y], 1);
      } else
        T_add(1, nls, a[x] + 1, ma, sz[y], 1);
    }
    T_add(1, nls, a[x] + 1, ma, 1, 1);
    if (T[1].mi >= 0) ans = Ls[ma] - Ls[a[x]];
    for (int kk = B.h[x]; kk; kk = B.E[kk].n) {
      int y = B.E[kk].s;
      if (a[y] < ma) {
        if (a[x] < a[y]) T_add(1, nls, a[x] + 1, a[y], -sz[y], 1);
      } else
        T_add(1, nls, a[x] + 1, ma, -sz[y], 1);
    }
    T_add(1, nls, a[x] + 1, ma, -1, 1);
  }
  if (ans == oo)
    puts("-1");
  else
    printf("%d\n", ans);
}