#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
int n, m, cc, lst, hd[N], h[N], b[N], mn[N], smn[N], c[N];
struct E {
  int v, nxt;
} e[N << 1];
struct st {
  int mn, tg;
} T[N << 2];
set<pair<int, int> > S;
set<pair<int, int> >::iterator it;
vector<int> V[N];
inline void add(int u, int v) {
  e[++cc] = (E){v, hd[u]};
  hd[u] = cc;
  e[++cc] = (E){u, hd[v]};
  hd[v] = cc;
}
void dfs(int x, int p) {
  S.insert(make_pair(h[x], x));
  it = S.begin();
  mn[x] = it->first;
  V[it->second].push_back(x);
  it++;
  if (it != S.end())
    smn[x] = it->first;
  else
    smn[x] = 1 << 30;
  for (int i = hd[x]; i; i = e[i].nxt)
    if (e[i].v != p) dfs(e[i].v, x);
  S.erase(S.find(make_pair(h[x], x)));
}
inline void dn(int x) {
  if (T[x].tg)
    T[x << 1].mn += T[x].tg, T[x << 1].tg += T[x].tg,
        T[x << 1 | 1].mn += T[x].tg, T[x << 1 | 1].tg += T[x].tg, T[x].tg = 0;
}
inline void up(int x) { T[x].mn = min(T[x << 1].mn, T[x << 1 | 1].mn); }
void upd(int x, int l, int r, int tl, int tr, int v) {
  if (tl <= l && r <= tr) {
    T[x].mn += v;
    T[x].tg += v;
    return;
  }
  int mid = l + r >> 1;
  dn(x);
  if (tl <= mid) upd(x << 1, l, mid, tl, tr, v);
  if (tr > mid) upd(x << 1 | 1, mid + 1, r, tl, tr, v);
  up(x);
}
int qry(int x, int l, int r, int p) {
  if (l == r) return T[x].mn;
  int mid = l + r >> 1;
  dn(x);
  return p <= mid ? qry(x << 1, l, mid, p) : qry(x << 1 | 1, mid + 1, r, p);
}
void build(int x, int l, int r) {
  if (l == r) {
    T[x].mn = -(m - l + 1);
    return;
  }
  int mid = l + r >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  up(x);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
  for (int i = 1, u, v; i < n; i++) scanf("%d%d", &u, &v), add(u, v);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  sort(b + 1, b + m + 1);
  build(1, 1, m);
  dfs(1, 0);
  for (int i = 1; i <= n; i++) {
    c[i] = upper_bound(b + 1, b + m + 1, mn[i]) - b - 1;
    if (c[i]) upd(1, 1, m, 1, c[i], 1);
  }
  if (T[1].mn >= 0) {
    puts("0");
    return 0;
  }
  for (int i = m; i; i--)
    if (qry(1, 1, m, i) < 0) {
      lst = i;
      break;
    }
  int ans = 1 << 30;
  for (int i = 1; i <= n; i++)
    if (V[i].size() + T[1].mn >= 0) {
      if (h[i] >= b[lst]) continue;
      for (int j = 0; j < V[i].size(); j++) {
        int x = V[i][j], nw = min(b[lst], smn[x]);
        int p = upper_bound(b + 1, b + m + 1, nw) - b - 1;
        if (c[x] < p) upd(1, 1, m, c[x] + 1, p, 1);
      }
      if (T[1].mn >= 0) ans = min(ans, b[lst] - h[i]);
      for (int j = 0; j < V[i].size(); j++) {
        int x = V[i][j], nw = min(b[lst], smn[x]);
        int p = upper_bound(b + 1, b + m + 1, nw) - b - 1;
        if (c[x] < p) upd(1, 1, m, c[x] + 1, p, -1);
      }
    }
  if (ans == 1 << 30)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
