import sys

import itertools



N,M,R=list(map(int, input().split()))



d=[  [ float("inf") for j in range(N+1) ]  for i in range(N+1) ]



r=list(map(int, sys.stdin.readline().split()))



for _ in range(M):

	a,b,c=list(map(int, sys.stdin.readline().split()))

	d[a][b]=c

	d[b][a]=c





for _ in range(3):

	for i in range(1,N+1):

		for j in range(1,N+1):

			for k in range(1,N+1):

				d[i][j]=min(d[i][j], d[i][k]+d[k][j])





C=list(itertools.permutations(r))





ans=float("inf")

for x in C:

	tmp_ans=0

	for i in range(R-1):

		fro=x[i]

		to=x[i+1]

		tmp_ans+=d[fro][to]

	ans=min(ans, tmp_ans)



print(ans)

		
import sys

import itertools



N,M,R=list(map(int, input().split()))



d=[  [ float("inf") for j in range(N+1) ]  for i in range(N+1) ]



r=list(map(int, sys.stdin.readline().split()))



for _ in range(M):

	a,b,c=list(map(int, sys.stdin.readline().split()))

	d[a][b]=c

	d[b][a]=c



for k in range(1,N+1):

	for i in range(1,N+1):

		for j in range(1,N+1):

			d[i][j]=min(d[i][j], d[i][k]+d[k][j])





C=list(itertools.permutations(r))





ans=float("inf")

for x in C:

	tmp_ans=0

	for i in range(R-1):

		fro=x[i]

		to=x[i+1]

		tmp_ans+=d[fro][to]

	ans=min(ans, tmp_ans)



print(ans)

		
import sys
import itertools

N, M, R = list(map(int, input().split()))
d = [[float("inf") for j in range(N + 1)] for i in range(N + 1)]
r = list(map(int, sys.stdin.readline().split()))
for _ in range(M):
    a, b, c = list(map(int, sys.stdin.readline().split()))
    d[a][b] = c
    d[b][a] = c
for _ in range(3):
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            for k in range(1, N + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
C = list(itertools.permutations(r))
ans = float("inf")
for x in C:
    tmp_ans = 0
    for i in range(R - 1):
        fro = x[i]
        to = x[i + 1]
        tmp_ans += d[fro][to]
    ans = min(ans, tmp_ans)
print(ans)

import sys
import itertools

N, M, R = list(map(int, input().split()))
d = [[float("inf") for j in range(N + 1)] for i in range(N + 1)]
r = list(map(int, sys.stdin.readline().split()))
for _ in range(M):
    a, b, c = list(map(int, sys.stdin.readline().split()))
    d[a][b] = c
    d[b][a] = c
for k in range(1, N + 1):
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
C = list(itertools.permutations(r))
ans = float("inf")
for x in C:
    tmp_ans = 0
    for i in range(R - 1):
        fro = x[i]
        to = x[i + 1]
        tmp_ans += d[fro][to]
    ans = min(ans, tmp_ans)
print(ans)

-for _ in range(3): +for k in range(1, N + 1): -            for k in range(1, N + 1): -                d[i][j] = min(d[i][j], d[i][k] + d[k][j]) +            d[i][j] = min(d[i][j], d[i][k] + d[k][j])