#include using namespace std; int main(){ int N, M, K; cin >> N >> M >> K; vector R(K); for (int i = 0; i < K; i++){ cin >> R[i]; R[i]--; } vector A(M), B(M), C(M); for (int i = 0; i < M; i++){ cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--; } vector>> E(N); for (int i = 0; i < M; i++){ E[A[i]].push_back(make_pair(C[i], B[i])); E[B[i]].push_back(make_pair(C[i], A[i])); } vector id; id.push_back(0); id.push_back(N - 1); for (int i = 0; i < K; i++){ id.push_back(A[R[i]]); id.push_back(B[R[i]]); } int V = id.size(); vector> d(V, vector(V)); for (int i = 0; i < V; i++){ vector d2(N, -1); priority_queue, vector>, greater>> pq; pq.push(make_pair(0, id[i])); while (!pq.empty()){ int c = pq.top().first; int v = pq.top().second; pq.pop(); if (d2[v] == -1){ d2[v] = c; for (auto P : E[v]){ int w = P.second; if (d2[w] == -1){ pq.push(make_pair(c + P.first, w)); } } } } for (int j = 0; j < V; j++){ d[i][j] = d2[id[j]]; } } vector> T(V, vector(V, -1)); for (int i = 0; i < K; i++){ d[i * 2 + 2][i * 2 + 3] = C[R[i]]; d[i * 2 + 3][i * 2 + 2] = C[R[i]]; T[i * 2 + 2][i * 2 + 3] = i; T[i * 2 + 3][i * 2 + 2] = i; } vector> d2(1 << K, vector(V, -1)); priority_queue, vector>, greater>> pq; pq.push(make_tuple(0, 0, 0)); while (!pq.empty()){ int c = get<0>(pq.top()); int s = get<1>(pq.top()); int v = get<2>(pq.top()); pq.pop(); if (d2[s][v] == -1){ d2[s][v] = c; for (int i = 0; i < V; i++){ int s2 = s; if (T[v][i] != -1){ s2 |= 1 << T[v][i]; } if (d2[s2][i] == -1){ pq.push(make_tuple(c + d[v][i], s2, i)); } } } } cout << d2[(1 << K) - 1][1] << endl; }