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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 500007, __ = _ << 1;
int to[__], ne[__], he[_] = {0}, ecnt = 1;
inline void adde(int a, int b) {
  to[++ecnt] = b, ne[ecnt] = he[a], he[a] = ecnt;
}
inline void addde(int a, int b) { adde(a, b), adde(b, a); }
int n, m, hig[_], lim[_];
pair<int, int> fk[_];
void dfs(int x, int ff, int mi, int cmi) {
  if (lim[x] < lim[mi])
    cmi = mi, mi = x;
  else if (lim[x] < lim[cmi])
    cmi = x;
  fk[x] = make_pair(mi, cmi);
  for (int i = he[x]; i; i = ne[i]) {
    int b = to[i];
    if (b == ff) continue;
    dfs(b, x, mi, cmi);
  }
}
int ps[_] = {0}, lps = 0;
void finding(int l, int r, int now) {
  int ans = 0;
  for (int i = 1; i <= r - l + 1; i++) {
    int temp = 0;
    if (i <= lps)
      temp = ps[i];
    else if (now + i - lps - 1 <= m)
      temp = hig[now + i - lps - 1];
    ans = max(ans, temp - lim[fk[l + i - 1].first]);
    if (temp > lim[fk[l + i - 1].second]) return;
  }
  cout << ans << lf;
  exit(0);
}
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty();
  for (int i = 1; i <= n; i++) lim[i] = ty();
  for (int i = 1, a, b; i < n; i++) a = ty(), b = ty(), addde(a, b);
  m = ty();
  for (int i = 1; i <= m; i++) hig[i] = ty();
  sort(hig + 1, hig + m + 1, greater<int>());
  lim[0] = 2e9, dfs(1, 0, 0, 0);
  sort(fk + 1, fk + n + 1, [](pair<int, int> a, pair<int, int> b) {
    if (lim[a.first] != lim[b.first]) return lim[a.first] > lim[b.first];
    if (a.first != b.first) return a.first < b.first;
    return lim[a.second] > lim[b.second];
  });
  int las = 0;
  for (int i = 1; i <= m; i++)
    if (lim[fk[i].first] < hig[i]) las = i;
  for (int i = 1, j = 1, now = 1; i <= n; i = j + 1) {
    j = i;
    while (j < n && fk[j + 1].first == fk[i].first) j++;
    if (lps <= j - i + 1 && j >= las) finding(i, j, now);
    for (int k = i; k <= j; k++) {
      while (now <= m && hig[now] > lim[fk[k].first])
        ps[++lps] = hig[now], now++;
      now++;
    }
  }
  cout << -1 << lf;
  return 0;
}