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>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
using namespace std;
namespace output {
void __(short x) { cout << x; }
void __(unsigned x) { cout << x; }
void __(int x) { cout << x; }
void __(long long x) { cout << x; }
void __(unsigned long long x) { cout << x; }
void __(double x) { cout << x; }
void __(long double x) { cout << x; }
void __(char x) { cout << x; }
void __(const char* x) { cout << x; }
void __(const string& x) { cout << x; }
void __(bool x) { cout << (x ? "true" : "false"); }
template <class S, class T>
void __(const pair<S, T>& x) {
  __(1 ? "(" : ""), __(x.first), __(1 ? ", " : " "), __(x.second),
      __(1 ? ")" : "");
}
template <class T>
void __(const vector<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class T>
void __(const set<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class T>
void __(const multiset<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class S, class T>
void __(const map<S, T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
void pr() { cout << "\n"; }
template <class S, class... T>
void pr(const S& a, const T&... b) {
  __(a);
  if (sizeof...(b)) __(' ');
  pr(b...);
}
}  // namespace output
using namespace output;
const int MN = 5e5 + 5, LG = 20;
int N, M, K, i, j, x, y, a[MN], b[MN], h[MN], dep[MN], anc[LG][MN], st[3 * MN],
    lz[3 * MN], ans = 1 << 30, lo, hi, bs[MN], rev[MN];
vector<int> adj[MN];
vector<pair<int, int> > qu[MN];
pair<int, int> sp[LG][MN];
map<int, int> mp;
inline int H(int x) { return x >= 0 ? a[x] : 1 << 30; }
inline pair<int, int> cmp(pair<int, int>& i, pair<int, int>& j) {
  if (H(i.first) < H(j.first))
    return make_pair(i.first, H(i.second) < H(j.first) ? i.second : j.first);
  else
    return make_pair(j.first, H(i.first) < H(j.second) ? i.first : j.second);
}
void dfs(int n, int p) {
  anc[0][n] = p;
  sp[0][n].first = n;
  h[n] = min(h[n], a[n]);
  for (auto v : adj[n]) {
    if (v == p) continue;
    h[v] = h[n];
    dep[v] = dep[n] + 1;
    dfs(v, n);
  }
}
inline void upd_lz(int i, int s, int e) {
  if (lz[i]) {
    st[i] += lz[i];
    if (s != e) lz[2 * i] += lz[i], lz[2 * i + 1] += lz[i];
    lz[i] = 0;
  }
}
void upd(int i, int s, int e, int ss, int se, int val) {
  if (ss > se) return;
  upd_lz(i, s, e);
  if (s >= ss && e <= se) {
    lz[i] = val;
    upd_lz(i, s, e);
  } else {
    if ((s + e) / 2 < ss)
      upd(2 * i + 1, (s + e) / 2 + 1, e, ss, se, val),
          upd_lz(2 * i, s, (s + e) / 2);
    else if ((s + e) / 2 >= se)
      upd(2 * i, s, (s + e) / 2, ss, se, val),
          upd_lz(2 * i + 1, (s + e) / 2 + 1, e);
    else
      upd(2 * i, s, (s + e) / 2, ss, se, val),
          upd(2 * i + 1, (s + e) / 2 + 1, e, ss, se, val);
    st[i] = min(st[2 * i], st[2 * i + 1]);
  }
}
int qur(int i, int s, int e) {
  upd_lz(i, s, e);
  if (s == e) return st[i] < 0 ? s : s - 1;
  upd_lz(2 * i + 1, (s + e) / 2 + 1, e);
  if (st[2 * i + 1] < 0)
    return qur(2 * i + 1, (s + e) / 2 + 1, e);
  else
    return qur(2 * i, s, (s + e) / 2);
}
void solve(int n, int p) {
  if (qu[n].size()) {
    vector<int> vec, idx;
    sort(qu[n].begin(), qu[n].end(), [](pair<int, int> i, pair<int, int> j) {
      return i.second < j.second;
    });
    for (auto v : qu[n]) {
      vec.push_back(v.second);
      auto it = mp.upper_bound(v.second);
      if (it != mp.begin())
        it--, idx.push_back(it->second);
      else
        idx.push_back(0);
      upd(1, 1, M, 1, bs[v.first], -1);
    }
    if (st[1] + (int)vec.size() >= 0) {
      int val = max(a[n], rev[qur(1, 1, M)]);
      if (val <= vec[0]) ans = min(ans, val - a[n]);
    }
    for (i = 0; i < vec.size(); i++) {
      upd(1, 1, M, 1, idx[i], 1);
      if (st[1] + (int)vec.size() - i - 1 >= 0) {
        int val = max(a[n], rev[qur(1, 1, M)]);
        if ((i + 1 == vec.size() || val <= vec[i + 1]) && val >= vec[i])
          ans = min(ans, val - a[n]);
      }
    }
    for (i = 0; i < idx.size(); i++) upd(1, 1, M, 1, idx[i], -1);
    for (auto v : qu[n]) upd(1, 1, M, 1, bs[v.first], 1);
  }
  for (auto v : adj[n]) {
    if (v != p) solve(v, n);
  }
}
int main() {
  for (scanf("%d", &N), i = 1; i <= N; i++) scanf("%d", &a[i]);
  for (i = 1; i < N; i++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (scanf("%d", &K), i = 1; i <= K; i++) scanf("%d", &b[i]), mp[b[i]] = 0;
  i = 0;
  auto it = mp.begin();
  for (; it != mp.end(); it++) it->second = ++i, rev[i] = it->first;
  M = mp.size();
  memset(sp, -1, sizeof(sp));
  h[1] = a[1];
  dep[1] = 1;
  dfs(1, 0);
  for (j = 1; j < LG; j++) {
    for (i = 1; i <= N; i++) {
      anc[j][i] = anc[j - 1][anc[j - 1][i]];
      sp[j][i] = cmp(sp[j - 1][i], sp[j - 1][anc[j - 1][i]]);
    }
  }
  for (i = 1; i <= N; i++) {
    pair<int, int> hm(-1, -1);
    x = i;
    for (j = LG - 1; j >= 0; j--) {
      if ((1 << j) <= dep[x]) {
        hm = cmp(hm, sp[j][x]);
        x = anc[j][x];
      }
    }
    qu[hm.first].push_back({i, H(hm.second)});
  }
  for (i = 1; i <= N; i++) {
    auto it = mp.upper_bound(h[i]);
    if (it != mp.begin()) {
      it--, upd(1, 1, M, 1, it->second, 1);
      bs[i] = it->second;
    }
  }
  for (i = 1; i <= K; i++) upd(1, 1, M, 1, mp[b[i]], -1);
  solve(1, 0);
  if (ans == 1 << 30)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}