#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
struct Segment_Tree {
  int Min[N << 2], val[N << 2];
  void init(int o, int L, int R) {
    Min[o] = val[o] = -1;
    if (L < R) {
      init((o << 1), L, ((L + R) >> 1)),
          init((o << 1 | 1), ((L + R) >> 1) + 1, R);
      Min[o] = val[o] = -(R - L + 1);
    }
  }
  void add(int o, int L, int R, int x, int w) {
    if (L == R)
      Min[o] += w, val[o] += w;
    else {
      x <= ((L + R) >> 1) ? add((o << 1), L, ((L + R) >> 1), x, w)
                          : add((o << 1 | 1), ((L + R) >> 1) + 1, R, x, w);
      Min[o] = min(Min[(o << 1)], val[(o << 1)] + Min[(o << 1 | 1)]);
      val[o] += w;
    }
  }
} T;
int n, k;
int lim[N], h[N], fa[N], mn[N];
vector<int> G[N];
void DFS_init(int o) {
  for (int v : G[o]) {
    if (v == fa[o]) continue;
    mn[v] = min(mn[o], lim[v]);
    fa[v] = o;
    DFS_init(v);
  }
}
struct Node {
  int o, w;
  bool operator<(const Node& B) const { return w < B.w; }
};
bool vis[N];
int c;
priority_queue<Node> q;
bool greedy() {
  q.push((Node){1, mn[1]});
  for (int i = 1; i <= k; i++) {
    Node s = q.top();
    if (s.w < h[i]) {
      c = i;
      return false;
    }
    q.pop();
    vis[s.o] = true;
    for (int v : G[s.o])
      if (v != fa[s.o]) q.push((Node){v, mn[v]});
  }
  return true;
}
int p[N];
void DFS_change(int o, int val) {
  int np = lower_bound(h + c, h + k + 1, val, greater<int>()) - h;
  if (np != p[o]) {
    if (p[o] != k + 1) T.add(1, 0, k - c, p[o] - c, -1);
    p[o] = np;
    if (p[o] != k + 1) T.add(1, 0, k - c, p[o] - c, 1);
  }
  for (int v : G[o]) {
    if (v == fa[o]) continue;
    DFS_change(v, min(val, lim[v]));
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &lim[i]);
  for (int i = 2; i <= n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v), G[v].push_back(u);
  }
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) scanf("%d", &h[i]);
  sort(h + 1, h + k + 1, greater<int>());
  mn[1] = lim[1];
  DFS_init(1);
  if (greedy()) {
    puts("0");
    return 0;
  }
  T.init(1, 0, k - c);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      p[i] = lower_bound(h + c, h + k + 1, mn[i], greater<int>()) - h;
      if (p[i] != k + 1) T.add(1, 0, k - c, p[i] - c, 1);
    }
  int ans = 2e9;
  while (!q.empty()) {
    int o = q.top().o;
    q.pop();
    int cur = h[c] - mn[o];
    if (ans <= cur) continue;
    DFS_change(o, h[c]);
    if (T.Min[1] >= 0) ans = cur;
    DFS_change(o, mn[o]);
  }
  if (ans == int(2e9)) ans = -1;
  printf("%d\n", ans);
  return 0;
}
