#include <fstream>
using namespace std;
ifstream F("team.in");
ofstream G("team.out");
const int N = 510;
const int M = 55;
int cst[N][N],n,m,mm;
int d[M][M][M],dst[N];
int main()
{
F>>m>>n>>mm;
for (int i=1;i<=n;++i)
for (int j=1;j<=n;++j)
if ( i != j )
cst[i][j] = 1<<29;
for (int i=1,x,y,c;i<=mm;++i)
{
F>>x>>y>>c;
cst[x][y] = min(cst[x][y],c);
cst[y][x] = min(cst[y][x],c);
}
for (int k=1;k<=n;++k)
for (int i=1;i<=n;++i)
for (int j=1;j<=n;++j)
cst[i][j] = min(cst[i][j],cst[i][k]+cst[k][j]);
for (int i=1;i<=m;++i)
F>>dst[i];
dst[0] = 1;
for (int j=1;j<=m;++j)
for (int i=j;i>=1;--i)
for (int ds=0;ds<=m;++ds)
{
d[i][j][ds] = 1<<29;
for (int l=i;l<=j;++l)
{
int act = 0;
if ( i <= l-1 ) act += d[i][l-1][l];
if ( l+1 <= j ) act += d[l+1][j][l];
act += cst[dst[ds]][dst[l]];
d[i][j][ds] = min(d[i][j][ds],act);
}
}
G<<d[1][m][0]<<'\n';
}