#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
const int INF = (int)1e9;

int main(){
	int n, m, r,ans = INF;
	cin >> n >> m >> r;
	vector<int> rr(r);
	for(int i = 0; i < r; i++){
		cin >> rr[i];
	}
	sort(begin(rr), end(rr));
	vector<vector<int>> c(n + 1, vector<int>(n + 1, INF));
	for(int i = 0; i < m; i++){
		int a, b, x;
		cin >> a >> b >> x;
		c[a][b] = x;
		c[b][a] = x;
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
	do{
		int t = 0;
		for(int i = 1; i < r; i++){
			t += c[rr[i - 1]][rr[i]];
		}
		ans = min(ans, t);
	} while(next_permutation(begin(rr), end(rr)));
	cout << ans << endl;
	return 0;
}