#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) int idx,                  __attribute__((unused)) int LINE_NUM) {     cerr << endl;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   const long long MOD = (int)1e9 + 7;   const long long INF = 2e18 + 5;   struct hashLL {     size_t operator()(long long x) const {       x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);       x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);       x = x ^ (x >> 31);       return x;     }   };   long long inv(long long a, long long b) {     return 1 < a ? b - inv(b % a, a) * b / a : 1;   }   long long gcd(long long a, long long b, long long& x, long long& y) {     if (a == 0) {       x = 0;       y = 1;       return b;     }     long long x1, y1;     long long d = gcd(b % a, a, x1, y1);     x = y1 - (b / a) * x1;     y = x1;     return d;   }   long long distsq(long long x1, long long y1, long long x2, long long y2) {     return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);   }   const int N = 200001;   long long n, m, k, t, u, v;   string s;   unordered_set<int> ks;   unordered_map<int, vector<int>> g;   int visited[N];   long long tosink[N];   long long tosource[N];   void bfs(int start, long long arr[]) {     for (int i = 0; i < n + 1; i++) arr[i] = -1;     deque<int> q;     q.push_back(start);     arr[start] = 0;     while (!q.empty()) {       int n = q.size();       for (int i = 0; i < (n); i++) {         int curr = q.front();         q.pop_front();         for (int c : g[curr]) {           if (arr[c] == -1) {             arr[c] = arr[curr] + 1;             q.push_back(c);           }         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m >> k;     for (int i = 0; i < (k); i++) {       cin >> u;       ks.emplace(u);     }     for (int i = 0; i < (m); i++) {       cin >> u >> v;       g[u].push_back(v);       g[v].push_back(u);     }     bfs(1, tosource);     bfs(n, tosink);     vector<pair<int, int>> tok;     map<int, unordered_set<int>> towardssink;     for (auto& p : ks) {       tok.push_back(make_pair(tosource[p], p));       towardssink[-tosink[p]].emplace(p);     }     sort((tok).begin(), (tok).end());     long long best = 0;     for (auto& p : tok) {       long long mintosource = p.first;       long long node = p.second;       towardssink[-tosink[node]].erase(node);       if (towardssink[-tosink[node]].empty()) {         towardssink.erase(-tosink[node]);       }       if (towardssink.empty()) break;       auto& pr = *towardssink.begin();       long long mxtosink = -pr.first;       long long curr = 1;       curr = curr + mintosource + min(tosink[node], mxtosink);       best = max(best, curr);     }     long long normaldist = tosink[1];     if (best < normaldist) {       cout << best << endl;     } else {       cout << normaldist << endl;     }   }