#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 2e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int n, m, a[MAX_N], mx[MAX_N];
vector<int> adj[MAX_N];

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
    }
    int ans = -INF;
    for (int u = n; u > 0; u--) {
        if (adj[u].empty()) {
            mx[u] = a[u];
            continue;
        }
        for (int v : adj[u]) mx[u] = max(mx[u], mx[v]);
        ans = max(ans, mx[u] - a[u]);
        mx[u] = max(mx[u], a[u]); 
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define ul unsigned long long
#define ui unsigned int
#define ri register int
#define pb push_back
#define mp make_pair
char p[30]={'0','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
inline ll rd(){
	ll x=0,flag=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') flag=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
	return x*flag;
}
#define N 100010
int wl,x,y,head[N],a[22][22],dp[132010][19],dis[N],c[22],vis[N],k,n,m,q[N],l,r;
struct node{
	int nxt,to;
}star[N<<1];
inline void add(int from,int to){
	wl++;
	star[wl].to=to;
	star[wl].nxt=head[from];
	head[from]=wl;
}
inline void bfs(int x){
    dis[x]=0;l=1,r=0;
    q[++r]=x;
    while(l<=r){
        int u=q[l++];
        for(ri i=head[u];i;i=star[i].nxt){
            int v=star[i].to;
            if(dis[v]!=0x3f3f3f3f) continue;
            dis[v]=dis[u]+1;q[++r]=v;
        }
    }
}
int main()
{
	n=rd(),m=rd();
	for(ri i=1;i<=m;++i) x=rd(),y=rd(),add(x,y),add(y,x);
	k=rd();
	for(ri i=1;i<=k;++i) c[i]=rd();
	for(ri i=1;i<=k;++i){
        memset(dis,0x3f,sizeof(dis));bfs(c[i]);
        for(ri j=i+1;j<=k;++j) a[i][j]=a[j][i]=dis[c[j]];
    }
    memset(dp,0x3f,sizeof(dp));
    for(ri i=1;i<=k;++i) dp[(1<<(i-1))][i]=1;
    for(ri s=0;s<(1<<k);++s){
        for(ri i=1;i<=k;++i){
            if((s&(1<<(i-1)))==0) continue;
            for(ri j=1;j<=k;++j){
                if(s&(1<<(j-1))) continue;
                dp[s^(1<<(j-1))][j]=min(dp[s^(1<<(j-1))][j],dp[s][i]+a[i][j]);
            }
        }
    }
    int ans=0x3f3f3f3f;
    for(ri i=1;i<=k;++i) ans=min(ans,dp[(1<<k)-1][i]);
    if(ans==0x3f3f3f3f) puts("-1");
    else
    cout<<ans;
    return 0;
}