#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long mod) {
  if (y < 0) return power(power(x, mod - 2, mod), -y, mod);
  long long res = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1) res = res * x % mod;
  return res;
}
const int nn = 501234;
set<pair<int, int> > A;
set<pair<int, int> >::iterator it;
int id, N, K, a[nn], b[nn], fa[nn];
vector<int> e[nn];
void dfs(int x) {
  for (int i = 0; i <= ((int)e[x].size()) - 1; ++i) {
    int j = e[x][i];
    if (j == fa[x]) continue;
    fa[j] = x;
    dfs(j);
  }
}
int find(int x) { return upper_bound(b + 1, b + 1 + id, x) - b - 1; }
struct seg {
  int a[nn * 4], b[nn * 4];
  void push(int p) {
    if (!a[p]) return;
    int lc = p << 1, rc = lc + 1;
    a[lc] += a[p];
    a[rc] += a[p];
    b[lc] += a[p];
    b[rc] += a[p];
    a[p] = 0;
  }
  void add(int p, int l, int r, int x, int y, int z) {
    if (l > r) return;
    if (x <= l && r <= y) {
      a[p] += z;
      b[p] += z;
      return;
    }
    int mid = l + r >> 1, lc = p << 1, rc = lc + 1;
    push(p);
    if (x <= mid) add(lc, l, mid, x, y, z);
    if (mid < y) add(rc, mid + 1, r, x, y, z);
    b[p] = min(b[lc], b[rc]);
  }
  void build(int p, int l, int r) {
    if (l > r) return;
    b[p] = -(id - l);
    if (l == r) return;
    int mid = l + r >> 1, lc = p << 1, rc = lc + 1;
    build(lc, l, mid);
    build(rc, mid + 1, r);
  }
  int query(int p, int l, int r, int x, int y) {
    if (l > r || x > y) return 1e9;
    if (x <= l && r <= y) return b[p];
    int mid = l + r >> 1, lc = p << 1, rc = lc + 1;
    push(p);
    int res = 1e9;
    if (x <= mid) res = min(res, query(lc, l, mid, x, y));
    if (mid < y) res = min(res, query(rc, mid + 1, r, x, y));
    return res;
  }
} T;
void dfs1(int x, int mm, int d) {
  mm = min(mm, a[x]);
  if (mm < b[1]) return;
  T.add(1, 1, id, 1, find(mm), d);
  for (int i = 0; i <= ((int)e[x].size()) - 1; ++i) {
    int j = e[x][i];
    if (j == fa[x]) continue;
    dfs1(j, mm, d);
  }
}
bool chk(int x) {
  dfs1(x, 1e9, -1);
  for (int i = 0; i <= ((int)e[x].size()) - 1; ++i) {
    int j = e[x][i];
    if (j == fa[x]) continue;
    dfs1(j, 1e9, 1);
  }
  int flag = T.query(1, 1, id, 1, id - 1) >= 0;
  dfs1(x, 1e9, 1);
  for (int i = 0; i <= ((int)e[x].size()) - 1; ++i) {
    int j = e[x][i];
    if (j == fa[x]) continue;
    dfs1(j, 1e9, -1);
  }
  return flag;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", a + i);
  for (int i = 1; i <= N - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(1);
  scanf("%d", &K);
  for (int i = 1; i <= K; ++i) scanf("%d", b + i);
  sort(b + 1, b + 1 + K);
  id = K;
  A.insert(make_pair(a[1], 1));
  while (id) {
    it = --A.end();
    if (it->first < b[id]) break;
    int x = it->second, y = it->first;
    A.erase(it);
    id--;
    for (int i = 0; i <= ((int)e[x].size()) - 1; ++i) {
      int j = e[x][i];
      if (j == fa[x]) continue;
      A.insert(make_pair(min(y, a[j]), j));
    }
  }
  if (!id) return puts("0"), 0;
  T.build(1, 1, id);
  for (it = A.begin(); it != A.end(); ++it) {
    dfs1(it->second, 1e9, 1);
  }
  int res = 2e9;
  for (it = A.begin(); it != A.end(); ++it) {
    if (chk(it->second)) res = min(res, b[id] - it->first);
  }
  printf("%d\n", res == 2e9 ? -1 : res);
}
