#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)
 
#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 998244353;

signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    vector<pair<int, int> > p(m);
    rep(i,m) {
        int x,y;
        cin>>x>>y;
        x--; y--;
        p[i] = make_pair(x,y);
    }
    sort(p.begin(),p.end());
    vector<int> b(n,inf);
    rep(i,m) {
        int x = p[i].first;
        int y = p[i].second;
        b[y]=min(b[y],min(b[x], a[x]));
        // cout<< x<<" "<<y<<endl;
    }
    int ans = -inf;
    rep(i,n) {
        if(b[i]==inf)continue;
        ans = max(a[i]-b[i],ans);
        // cout<< b[i]<<endl;
    }
    cout<<ans<<endl;
   return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int N,M,K;
vector<vector<int>> d(17,vector<int>(17,1e9));
vector<vector<int>> dp(1<<17, vector<int>(17, 1e9));

int rec(int S,int v){
  if((S&(1<<v))==0) return 1e9;
  int &ret = dp[S][v];
  if(ret<5*1e8) return ret;
  rep(u,K){
    chmin(ret,rec(S^(1<<v),u)+d[u][v]);
  }
  return ret;
}

int main(){
  cin >> N >> M;
  vector<pair<int,int>> AB(M); rep(i,M) cin >> AB[i].first >> AB[i].second;
  cin >> K;
  vector<int> C(K);
  rep(i,K) cin >> C[i];
  rep(i,K) C[i]--;

  vector<vector<int>> G(N);
  rep(i,M){
    int a = AB[i].first-1;
    int b = AB[i].second-1;
    G[a].pb(b);
    G[b].pb(a);
  }

  const int inf = 1e9;

  rep(i,K){
    vector<int> D(N,-1);
    queue<int> q;
    q.push(C[i]); D[C[i]] = 0;
    while(!q.empty()){
      int now = q.front(); q.pop();
      rep(x,sz(G[now])){
        int nxt=G[now][x];
        if(D[nxt]>=0) continue;
        q.push(nxt);
        D[nxt] = D[now]+1;
      }
    }
    rep(j,K){
      if(D[C[j]]!=-1) chmin(d[i][j], D[C[j]]);
    }
  }

  rep(i,K) d[i][i] = 0;
  rep(k,K) rep(i,K) rep(j,K) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);

  rep(i,K){
    int now=(1<<i);
    dp[now][i]=1;
  }
  int ans = 1e9;
  /*
  rep(i,K){
    chmin(ans, rec((1<<K)-1, i));
  }*/

  for(int bit=1;bit<(1<<K);bit++){
    rep(i,K){
      if(bit&(1<<i)){
        int bit2=bit^(1<<i);
        rep(j,K) if(bit2&(1<<j)) chmin(dp[bit][i], dp[bit2][j]+d[i][j]);
      }
    }
  }



  rep(i,K) chmin(ans, dp[(1<<K)-1][i]);
  if(ans>5*1e8){
    cout << -1 << endl;
  }
  else cout << ans << endl;

  return 0;
}
