#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"def solve():\n"
"    from itertools import permutations\n"
"    n,m,R=map(int,input().split())\n"
"    r=map(int,input().split())\n"
"    d=[[10**18]*n for _ in range(n)]\n"
"    for i in range(m):\n"
"        a,b,c=map(int,input().split())\n"
"        d[a-1][b-1]=c\n"
"        d[b-1][a-1]=c\n"
"    for i in range(n):\n"
"        d[i][i]=0\n"
"    for k in range(n):\n"
"        for i in range(n):\n"
"            for j in range(n):\n"
"                t=d[i][k]+d[k][j]\n"
"                if t<d[i][j]:\n"
"                    d[i][j]=t\n"
"    m=10**18\n"
"    for e in permutations(r):\n"
"        t=0\n"
"        for i,j in zip(e,e[1:]):\n"
"            t+=d[i-1][j-1]\n"
"        if t<m:\n"
"            m=t\n"
"    print(m)\n"
"if __name__=='__main__':\n"
"    solve()\n"
"\"";
  system(s);
  return 0;
}            