#include <bits/stdc++.h>
using namespace std;
int N, M, D, L, B[500005], H[500005], G[500005], st[500005];
struct Lin {
  int v, next;
} E[500005 * 2];
struct Nod {
  int a, b;
} A[500005];
int IN() {
  int x = 0, ch;
  for (; (ch = getchar()) < '0' || ch > '9';)
    ;
  for (; ch >= '0' && ch <= '9'; (ch = getchar())) (x *= 10) += ch - '0';
  return x;
}
void Link(int u, int v) {
  E[++D] = (Lin){v, st[u]};
  st[u] = D;
  E[++D] = (Lin){u, st[v]};
  st[v] = D;
}
void DFS(int u, int f, int a, int b) {
  if (H[u] < H[a])
    b = a, a = u;
  else if (H[u] < H[b])
    b = u;
  A[u] = (Nod){a, b};
  for (int i = st[u], v; i; i = E[i].next)
    if ((v = E[i].v) ^ f) DFS(v, u, a, b);
}
bool Cmp1(Nod a, Nod b) {
  if (H[a.a] != H[b.a]) return H[a.a] > H[b.a];
  if (a.a != b.a) return a.a < b.a;
  return H[a.b] > H[b.b];
}
bool Cmp2(int a, int b) { return a > b; }
void Work(int l, int r, int k) {
  int ret = 0;
  for (int i = 1; i <= r - l + 1; i++) {
    int t = 0;
    if (i <= *G)
      t = G[i];
    else if (k + i - *G - 1 <= M)
      t = B[k + i - *G - 1];
    ret = max(ret, t - H[A[l + i - 1].a]);
    if (t > H[A[l + i - 1].b]) return;
  }
  printf("%d\n", ret);
  exit(0);
}
int main() {
  N = IN();
  for (int i = 1; i <= N; i++) H[i] = IN();
  for (int i = 2; i <= N; i++) Link(IN(), IN());
  M = IN();
  for (int i = 1; i <= M; i++) B[i] = IN();
  H[0] = 1 << 30;
  DFS(1, 0, 0, 0);
  sort(A + 1, A + N + 1, Cmp1);
  sort(B + 1, B + M + 1, Cmp2);
  for (int i = 1; i <= M; i++)
    if (H[A[i].a] < B[i]) L = i;
  for (int i = 1, j = 1, k = 1; i <= N; i = j + 1) {
    for (j = i; j < N && A[j + 1].a == A[i].a; j++)
      ;
    if (*G <= j - i + 1 && j >= L) Work(i, j, k);
    for (int t = i; t <= j; t++) {
      for (; k <= M && B[k] > H[A[t].a]; k++) G[++*G] = B[k];
      k++;
    }
  }
  puts("-1");
}
