#include <bits/stdc++.h>
using namespace std;
pair<int, int> mn[500010];
vector<int> cv[500010];
int l[500010], tot, a[500010], b[500010];
struct Edge {
  int to, old;
} e[500010 * 2];
inline void Lnk(int x, int y) {
  e[++tot].to = y, e[tot].old = l[x], l[x] = tot;
}
inline void Dfs(int x, int y) {
  mn[x] = mn[y];
  if (a[mn[x].first] > a[x])
    mn[x].second = mn[x].first, mn[x].first = x;
  else {
    if (a[mn[x].second] > a[x]) mn[x].second = x;
  }
  for (int i = l[x]; i; i = e[i].old)
    if (e[i].to != y) Dfs(e[i].to, x);
}
int ko[500010], n, m;
inline int Find(int x) {
  int l = 1, r = m, rs = 0;
  while (l <= r) {
    int md = (l + r) / 2;
    if (b[md] <= x)
      l = md + 1, rs = md;
    else
      r = md - 1;
  }
  return (rs);
}
int ad[500010 * 4], t[500010 * 4], ans, tg;
inline void Down(int x) {
  t[x * 2] += ad[x], t[x * 2 + 1] += ad[x];
  ad[x * 2] += ad[x], ad[x * 2 + 1] += ad[x], ad[x] = 0;
}
inline void Build(int x, int l, int r) {
  if (l == r) {
    t[x] = m - l + 1;
    return;
  }
  int md = (l + r) / 2;
  Build(x * 2, l, md), Build(x * 2 + 1, md + 1, r);
  t[x] = max(t[x * 2], t[x * 2 + 1]);
}
inline int Find(int x, int l, int r) {
  if (l == r) {
    if (t[x] > 0) return (l);
    return (0);
  }
  Down(x);
  int md = (l + r) / 2;
  return (max(Find(x * 2, l, md), Find(x * 2 + 1, md + 1, r)));
}
inline void Add(int x, int l, int r, int a, int b, int c) {
  if (a == l && b == r) {
    t[x] += c, ad[x] += c;
    return;
  }
  int md = (l + r) / 2;
  Down(x);
  if (b <= md) Add(x * 2, l, md, a, b, c);
  if (md < a) Add(x * 2 + 1, md + 1, r, a, b, c);
  if (a <= md && md < b)
    Add(x * 2, l, md, a, md, c), Add(x * 2 + 1, md + 1, r, md + 1, b, c);
  t[x] = max(t[x * 2], t[x * 2 + 1]);
}
int q[500010], ko1[500010];
bool Cmp1(int x, int y) { return (ko1[x] < ko1[y]); }
inline bool Check(int x) {
  if (ko1[x] < tg) return (0);
  if (ko[x]) Add(1, 1, m, 1, ko[x], cv[x].size());
  for (int i = 0; i < cv[x].size(); i++) {
    int ii = cv[x][i];
    if (min(ko1[ii], tg)) Add(1, 1, m, 1, min(ko1[ii], tg), -1);
  }
  int rs = (t[1] <= 0);
  if (ko[x]) Add(1, 1, m, 1, ko[x], -cv[x].size());
  for (int i = 0; i < cv[x].size(); i++) {
    int ii = cv[x][i];
    if (min(ko1[ii], tg)) Add(1, 1, m, 1, min(ko1[ii], tg), 1);
  }
  return (rs);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Lnk(x, y), Lnk(y, x);
  }
  a[0] = 1e9 + 1;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  sort(b + 1, b + 1 + m);
  Dfs(1, 0);
  for (int i = 1; i <= n; i++) cv[mn[i].first].push_back(i);
  Build(1, 1, m);
  ko1[0] = ko[0] = m;
  for (int i = 1; i <= n; i++) {
    ko[i] = Find(a[mn[i].first]);
    ko1[i] = Find(a[mn[i].second]);
    if (ko[i]) Add(1, 1, m, 1, ko[i], -1);
  }
  if (t[1] <= 0) {
    puts("0");
    return (0);
  }
  tg = Find(1, 1, m), ans = -1;
  for (int i = 1; i <= n; i++)
    if (Check(i)) ans = max(ans, a[i]);
  if (ans == -1)
    puts("-1");
  else
    printf("%d\n", b[tg] - ans);
}
