#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
ll n, m, r, s, ans = 2e9, a[10], d[205][205];
int main()
{
	ll i, j, k, t1,t2, t3;
	cin>> n >> m >> r;
	for (i = 0; i < r; i++) scanf("%lld", &a[i]);
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) d[i][j] = 2e9;
		d[i][i] = 0;
	}
	while (m--) {
		scanf ("%lld %lld %lld", &t1, &t2, &t3);
		d[t1][t2] = min(d[t1][t2], t3);
		d[t2][t1] = min(d[t2][t1], t3);
	}
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
		}
	}
	sort(a, a + r);
	do {
		s =0;
		for (i = 1; i < r; i++) s += d[a[i]][a[i - 1]];
		ans = min(ans, s);
	} while(next_permutation(a, a + r));
	cout << ans;
    return 0;
}
