#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 500000;
const int MAXM = MAXN - 1;
int n;
int lim[MAXN], have[MAXN];
int fst[MAXN], nxt[2 * MAXM], to[2 * MAXM];
int par[MAXN];
int nwant;
int want[MAXN];
int shave[MAXN];
int nlft;
int lft[MAXN];
int ncand;
int cand[MAXN];
int ngain;
int gain[MAXN];
void dfs(int at) {
  have[at] = lim[at];
  if (par[at] != -1 && have[par[at]] < have[at]) have[at] = have[par[at]];
  for (int x = fst[at]; x != -1; x = nxt[x]) {
    if (to[x] == par[at]) continue;
    par[to[x]] = at;
    dfs(to[x]);
  }
}
void getcand(int at, int maxolim, int nlim) {
  if (lim[at] <= maxolim) {
    cand[ncand++] = at;
    return;
  }
  if (lim[at] < nlim) return;
  for (int x = fst[at]; x != -1; x = nxt[x])
    if (to[x] != par[at]) getcand(to[x], maxolim, nlim);
}
void getgain(int at, int nlim) {
  if (nlim <= have[at]) return;
  gain[ngain++] = nlim;
  for (int x = fst[at]; x != -1; x = nxt[x]) {
    if (to[x] == par[at]) continue;
    getgain(to[x], min(nlim, lim[to[x]]));
  }
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &lim[i]);
  for (int i = (0); i < (n); ++i) fst[i] = -1;
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    nxt[2 * i + 0] = fst[a];
    fst[a] = 2 * i + 0;
    to[2 * i + 0] = b;
    nxt[2 * i + 1] = fst[b];
    fst[b] = 2 * i + 1;
    to[2 * i + 1] = a;
  }
  scanf("%d", &nwant);
  for (int i = (0); i < (nwant); ++i) scanf("%d", &want[i]);
  while (nwant < n) want[nwant++] = 0;
  sort(want, want + n);
  par[0] = -1;
  dfs(0);
  for (int i = (0); i < (n); ++i) shave[i] = have[i];
  sort(shave, shave + n);
  int nlim = -1;
  for (int i = (0); i < (n); ++i)
    if (want[i] > shave[i]) nlim = want[i];
  if (nlim == -1) {
    printf("0\n");
    return;
  }
  int maxolim = -1;
  for (int i = (0); i < (n); ++i)
    if (shave[i] < want[i]) {
      maxolim = shave[i];
      break;
    }
  ncand = 0;
  getcand(0, maxolim, nlim);
  nlft = 0;
  for (int i = n - 1, j = n - 1; i >= 0; --i)
    if (want[i] <= shave[j])
      --j;
    else
      lft[nlft++] = want[i];
  sort(lft, lft + nlft);
  int ret = -1;
  for (int i = (0); i < (ncand); ++i) {
    int cur = nlim - lim[cand[i]];
    if (ret != -1 && cur > ret) continue;
    ngain = 0;
    getgain(cand[i], nlim);
    if (ngain < nlft) continue;
    sort(gain, gain + ngain);
    bool ok = true;
    for (int j = (0); j < (nlft); ++j)
      if (lft[j] > gain[ngain - nlft + j]) {
        ok = false;
        break;
      }
    if (!ok) continue;
    ret = cur;
  }
  printf("%d\n", ret);
}
int main() {
  run();
  return 0;
}
