#include #include #include #define rep(i, l, n) for (int i = (l); i < (n); i++) #define all(x) x.begin(), x.end() using namespace std; template using V = vector; template using VV = V >; const int inf = 1000000000; void warshall_floyd(int N, VV&dist) { rep(i, 0, N) { dist[i][i] = 0; } rep(k, 0, N) { rep(i, 0, N) { rep(j, 0, N) { int d = dist[i][k] + dist[k][j]; if (dist[i][j] > d) { dist[i][j] = d; } } } } } int main(void) { int N, M, K; cin >> N >> M >> K; V R(K); rep(i, 0, K) { cin >> R[i]; R[i] -= 1; } sort(all(R)); VV edge(M, V(3)); VV dist(N, V(N, inf)); rep(i, 0, M) { rep(j, 0, 3) { cin >> edge[i][j]; } edge[i][0] -= 1; edge[i][1] -= 1; int a = edge[i][0]; int b = edge[i][1]; dist[a][b] = dist[b][a] = edge[i][2]; } warshall_floyd(N, dist); int ans = inf; int rsum = 0; rep(i, 0, R.size()) { rsum += edge[R[i]][2]; } do { rep(bit, 0, 1 << K) { int s = rsum; V path(1); rep(i, 0, K) { int b = (bit >> i) & 1; path.push_back(edge[R[i]][b]); path.push_back(edge[R[i]][b ^ 1]); } path.push_back(N - 1); for (int i = 0; i < path.size() - 1; i += 2) { s += dist[path[i]][path[i + 1]]; } if (ans > s) { ans = s; } } } while (next_permutation(all(R))); cout << ans << endl; return 0; }