#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[500500];
int h[500500], H[500500], s[500500];
int fa[500500];
struct pnt {
  int id, val;
  pnt(int id = 0, int val = 0) : id(id), val(val) {}
};
bool operator<(pnt a, pnt b) {
  return a.val != b.val ? a.val > b.val : a.id < b.id;
}
set<pnt> Set;
void input() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", h + i);
  for (int x, y, i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", s + i);
  sort(s + 1, s + m + 1);
}
int tot;
vector<int> w[500500];
int st[500500];
void prepare() {
  Set.insert(pnt(1, h[1]));
  while (!Set.empty()) {
    set<pnt>::iterator it = Set.begin();
    if (it->val >= s[m]) {
      if (!--m) {
        puts("0");
        exit(0);
      }
      int x = it->id;
      int hh = it->val;
      for (int y, i = 0; i < v[x].size(); i++) {
        y = v[x][i];
        if (y == fa[x]) continue;
        fa[y] = x;
        Set.insert(pnt(y, min(h[y], hh)));
      }
      Set.erase(it);
    } else
      break;
  }
  tot = 0;
  for (set<pnt>::iterator it = Set.begin(); it != Set.end(); it++) {
    int x = it->id;
    H[x] = s[m];
    st[++tot] = it->val;
    queue<int> q;
    q.push(x);
    while (!q.empty()) {
      int y = q.front();
      q.pop();
      w[tot].push_back(H[y]);
      for (int z, i = 0; i < v[y].size(); i++) {
        if ((z = v[y][i]) == fa[y]) continue;
        fa[z] = y;
        H[z] = min(H[y], h[z]);
        q.push(z);
      }
    }
    sort(w[tot].begin(), w[tot].end());
  }
}
int mn[500500 << 2], add[500500 << 2];
void push_up(int id) { mn[id] = min(mn[id << 1], mn[id << 1 | 1]); }
void push_down(int id) {
  if (add[id]) {
    add[id << 1] += add[id];
    add[id << 1 | 1] += add[id];
    mn[id << 1] += add[id];
    mn[id << 1 | 1] += add[id];
    add[id] = 0;
  }
}
void change(int id, int st, int en, int a, int b, int v) {
  if (a <= st && en <= b) {
    mn[id] += v;
    add[id] += v;
    return;
  }
  push_down(id);
  int mid = (st + en) >> 1;
  if (a <= mid) change(id << 1, st, mid, a, b, v);
  if (mid + 1 <= b) change(id << 1 | 1, mid + 1, en, a, b, v);
  push_up(id);
}
void make_tree(int id, int st, int en) {
  if (st == en) {
    mn[id] = st - 1 - m;
    return;
  }
  int mid = (st + en) >> 1;
  make_tree(id << 1, st, mid);
  make_tree(id << 1 | 1, mid + 1, en);
  push_up(id);
}
void solve() {
  make_tree(1, 1, m);
  for (int i = 1; i <= tot; i++) {
    for (int x, j = 0; j < w[i].size(); j++) {
      int k = upper_bound(s + 1, s + m + 1, min(st[i], w[i][j])) - s - 1;
      if (k) change(1, 1, m, 1, k, 1);
    }
  }
  for (int i = 1; i <= tot; i++) {
    for (int x, j = 0; j < w[i].size(); j++) {
      int k1 = upper_bound(s + 1, s + m + 1, min(st[i], w[i][j])) - s - 1;
      int k2 = upper_bound(s + 1, s + m + 1, w[i][j]) - s - 1;
      if (k1 < k2) change(1, 1, m, k1 + 1, k2, 1);
    }
    if (mn[1] >= 0) {
      printf("%d\n", s[m] - st[i]);
      return;
    }
    for (int x, j = 0; j < w[i].size(); j++) {
      int k1 = upper_bound(s + 1, s + m + 1, min(st[i], w[i][j])) - s - 1;
      int k2 = upper_bound(s + 1, s + m + 1, w[i][j]) - s - 1;
      if (k1 < k2) change(1, 1, m, k1 + 1, k2, -1);
    }
  }
  puts("-1");
}
int main() {
  input();
  prepare();
  solve();
  return 0;
}
