#include <bits/stdc++.h>
using namespace std;
const int N=510,P=810,M=1460;
int cow[N];
long long dist[P];
int c,n,m;
int h[M],e[M],ne[M],w[M],idx;
bool st[P];
void add(int a,int b,int c)
{
idx++;
e[idx]=b,ne[idx]=h[a],w[idx]=c,h[a]=idx;
}
void spfa(int S)
{
memset(dist,0x3f,sizeof(dist));
memset(st,false,sizeof(st));
queue<int> q;
q.push(S);
st[S]=true;
dist[S]=0;
while(!q.empty())
{
int t=q.front();
q.pop();
st[t]=false;
for(int i=h[t];i;i=ne[i])
{
int j=e[i];
if(dist[j]>dist[t]+w[i])
{
dist[j]=dist[t]+w[i];
if(!st[j])
{
q.push(j);
st[j]=true;
}
}
}
}
}
int main()
{
scanf("%d %d %d",&c,&n,&m);
for(int i=1;i<=c;i++)scanf("%d",&cow[i]);
while(m--)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
add(a,b,c);
add(b,a,c);
}
long long ans=0x3f3f3f3f3f3f3f3f;
for(int i=1;i<=n;i++)
{
long long tot=0;
spfa(i);
for(int j=1;j<=c;j++)
tot+=1LL*dist[cow[j]];
ans=min(ans,tot);
}
printf("%lld\n",ans);
return 0;
}