import sys import itertools import heapq as hq N,M,K = map(int,sys.stdin.readline().split()) R = [i-1 for i in map(int,sys.stdin.readline().split())] route = [[] for _ in [0]*N] edge = [0]*M for i in range(M): A,B,C = map(int,sys.stdin.readline().split()) A -= 1; B -= 1 edge[i] = [A,B,C] route[A].append((B,C)) route[B].append((A,C)) def dijkstra(route,start,finish,n): path = [-1]*n q = [(0,start)] while(q): d,v = hq.heappop(q) if(path[v] == -1): path[v] = d if(v == finish): break for nv,dist in route[v]: hq.heappush(q,(d+dist,nv)) return path[finish] ans = float("inf") rsum = sum(edge[i][2] for i in R) dist = [[0]*N for _ in [0]*N] for rlist in itertools.permutations(R): for bit in range(1 << K): s = rsum path = [0] for i in range(K): if(bit & (1 << i)): path.append(edge[rlist[i]][0]) path.append(edge[rlist[i]][1]) else: path.append(edge[rlist[i]][1]) path.append(edge[rlist[i]][0]) path.append(N-1) for i in range(0,len(path)-1,2): if(dist[path[i]][path[i+1]] == 0): dist[path[i]][path[i+1]] = dist[path[i+1]][path[i]] = dijkstra(route,path[i],path[i+1],N) s += dist[path[i]][path[i+1]] if(ans > s): ans = s print(ans)