#include <iostream>
#include <algorithm>
using namespace std;
int road[201][201],d[8];
int n,m,r,i,i2,i3,a,b,c;
bool f(int a,int b){return a<b;}
int main()
{
	cin>>n>>m>>r;
	for(i=0;i<r;i++)cin>>d[i];
	for(i=0;i<=n;i++)for(i2=0;i2<=n;i2++)road[i][i2]=1000000000;
	for(i=0;i<m;i++)
	{	
		cin>>a>>b>>c;
		road[a][b]=road[b][a]=c;
	}
	for(i3=1;i3<=n;i3++)
		for(i=1;i<=n;i++)
			for(i2=1;i2<=n;i2++)
				road[i][i2]=min(road[i][i2],road[i][i3]+road[i3][i2]);
	sort(d,d+r,f);
	b=2147483647;
	while(next_permutation(d,d+r))
	{
		a=0;
		for(i2=0;i2<r-1;i2++)a+=road[d[i2]][d[i2+1]];
		b=min(a,b);
	}
	cout << b<<"\n";
}