#include <bits/stdc++.h>
using namespace std;
const int N = (int)5e5 + 5;
const int inf = (int)1e9 + 7;
int n, m;
struct node;
struct edge {
  node *ed;
  edge *next;
} E[N << 1], *newE = E;
struct node {
  edge *son;
  int h, x, y;
  node *block;
  void dfs(node *fa) {
    x = fa->x;
    y = fa->y;
    block = fa->block;
    if (h < x)
      y = x, x = h, block = this;
    else if (h < y)
      y = h;
    for (edge *e = son; e; e = e->next)
      if (e->ed != fa) e->ed->dfs(this);
  }
} V[N], *a[N];
int b[N], c[N];
void addedge(node *u, node *v) { *newE = (edge){v, u->son}, u->son = newE++; }
void addedges(node *u, node *v) {
  addedge(u, v);
  addedge(v, u);
}
bool cmpa(const node *u, const node *v) {
  if (u->x != v->x) return u->x > v->x;
  if (u->block != v->block) return u->block < v->block;
  return u->y > v->y;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &V[i].h);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedges(V + x, V + y);
  }
  addedges(V, V + 1);
  V->h = V->x = V->y = inf;
  V->block = V;
  V[1].dfs(V);
  for (int i = 1; i <= n; i++) a[i] = V + i;
  sort(a + 1, a + n + 1, cmpa);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  sort(b + 1, b + m + 1, greater<int>());
  int L = m;
  while (L && a[L]->x >= b[L]) L--;
  int ans = inf;
  for (int i = 0, j, p = 1; i < n; i = j) {
    for (j = i; j < n && a[i + 1]->block == a[j + 1]->block;) ++j;
    if (j - i >= *c && j >= L) {
      int now = 0;
      for (int k = *c + 1; k <= j - i; k++) c[k] = b[i + k];
      for (int k = 1; k <= j - i; k++) {
        if (c[k] > a[i + k]->y) {
          now = inf;
          break;
        }
        now = max(now, c[k] - a[i + k]->x);
      }
      ans = min(ans, now);
    }
    for (j = i; j < n && a[i + 1]->block == a[j + 1]->block;) {
      ++j;
      for (; p <= n && b[p] > a[j]->x; p++) c[++*c] = b[p];
      if (p > n) goto outside;
      p++;
    }
  }
outside:;
  printf("%d\n", ans == inf ? -1 : ans);
}
