#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, m, l;
int b[N], h[N];
struct edge {
  int to, next;
} e[N * 2];
int head[N], tot;
pair<int, int> a[N];
int G[N];
bool cmp1(pair<int, int> a, pair<int, int> b) {
  if (h[a.first] != h[b.first]) return h[a.first] > h[b.first];
  if (a.first != b.first) return a.first < b.first;
  return h[a.second] > h[b.second];
}
bool cmp2(int x, int y) { return x > y; }
void add(int x, int y) {
  e[++tot] = (edge){y, head[x]};
  head[x] = tot;
}
void dfs(int x, int fa, int first, int second) {
  if (h[x] < h[first])
    second = first, first = x;
  else if (h[x] < h[second])
    second = x;
  a[x] = pair<int, int>(first, second);
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to != fa) dfs(e[i].to, x, first, second);
}
void work(int l, int r, int k) {
  int ans = 0;
  for (int i = (int)(1); i <= (int)(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];
    ans = max(ans, t - h[a[l + i - 1].first]);
    if (t > h[a[l + i - 1].second]) return;
  }
  printf("%d\n", ans);
  exit(0);
}
int main() {
  scanf("%d", &n);
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &h[i]);
  for (int i = (int)(2); i <= (int)(n); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  scanf("%d", &m);
  for (int i = (int)(1); i <= (int)(m); i++) scanf("%d", &b[i]);
  h[0] = (1ll << 30);
  dfs(1, 0, 0, 0);
  sort(a + 1, a + n + 1, cmp1);
  sort(b + 1, b + m + 1, cmp2);
  for (int i = (int)(1); i <= (int)(m); i++)
    if (h[a[i].first] < 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].first == a[i].first; j++)
      ;
    if (*G <= j - i + 1 && j >= l) work(i, j, k);
    for (int t = (int)(i); t <= (int)(j); t++) {
      for (; k <= m && b[k] > h[a[t].first]; k++) G[++*G] = b[k];
      k++;
    }
  }
  puts("-1");
}
