import itertools

inf = float("inf")

n,m,r = list(map(int,input().split()))

ra = list(map(int,input().split()))

dist = [[inf for i in range(n)] for i in range(n)]

for i in range(m):

    a,b,c = list(map(int,input().split()))

    dist[a-1][b-1] = c

    dist[b-1][a-1] = c



for a in range(n):

    for b in range(n):

        for c in range(n):

            dist[b-1][c-1] = min(dist[b-1][c-1],dist[b-1][a-1]+dist[a-1][c-1])



#print("距離行列は以下")

#for i in range(n+1):

    #print(dist[i])



ans = inf

for p in itertools.permutations(ra):

    subt = 0

    for i in range(r-1):

        subt += dist[p[i]-1][p[i+1]-1]

    if subt < ans:

        ans = subt

print(ans)

inf = 10**15

import itertools

n,m,r = list(map(int,input().split()))

city = list(map(int,input().split()))





dist = [[inf for i in range(n)] for i in range(n)]



#まず距離を初期化(入力に従う)

for i in range(m):

    ak,bk,ck = list(map(int,input().split()))

    dist[ak-1][bk-1]  =ck

    dist[bk-1][ak-1]  =ck



for a in range(n):

    for b in range(n):

        for c in range(n):

            dist[b][c] = min(dist[b][c],dist[b][a]+dist[a][c])



#print(dist)



ans = inf

for v in itertools.permutations(city):

    cost = 0

    for i in range(len(v)-1):

        cost += dist[v[i]-1][v[i+1]-1]

    #print(v,cost)

    ans = min(ans,cost)



print(ans)

import itertools

inf = float("inf")
n, m, r = list(map(int, input().split()))
ra = list(map(int, input().split()))
dist = [[inf for i in range(n)] for i in range(n)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    dist[a - 1][b - 1] = c
    dist[b - 1][a - 1] = c
for a in range(n):
    for b in range(n):
        for c in range(n):
            dist[b - 1][c - 1] = min(
                dist[b - 1][c - 1], dist[b - 1][a - 1] + dist[a - 1][c - 1]
            )
# print("距離行列は以下")
# for i in range(n+1):
# print(dist[i])
ans = inf
for p in itertools.permutations(ra):
    subt = 0
    for i in range(r - 1):
        subt += dist[p[i] - 1][p[i + 1] - 1]
    if subt < ans:
        ans = subt
print(ans)

inf = 10**15
import itertools

n, m, r = list(map(int, input().split()))
city = list(map(int, input().split()))
dist = [[inf for i in range(n)] for i in range(n)]
# まず距離を初期化(入力に従う)
for i in range(m):
    ak, bk, ck = list(map(int, input().split()))
    dist[ak - 1][bk - 1] = ck
    dist[bk - 1][ak - 1] = ck
for a in range(n):
    for b in range(n):
        for c in range(n):
            dist[b][c] = min(dist[b][c], dist[b][a] + dist[a][c])
# print(dist)
ans = inf
for v in itertools.permutations(city):
    cost = 0
    for i in range(len(v) - 1):
        cost += dist[v[i] - 1][v[i + 1] - 1]
    # print(v,cost)
    ans = min(ans, cost)
print(ans)

+inf = 10**15 -inf = float("inf") -ra = list(map(int, input().split())) +city = list(map(int, input().split())) +# まず距離を初期化(入力に従う) -    a, b, c = list(map(int, input().split())) -    dist[a - 1][b - 1] = c -    dist[b - 1][a - 1] = c +    ak, bk, ck = list(map(int, input().split())) +    dist[ak - 1][bk - 1] = ck +    dist[bk - 1][ak - 1] = ck -            dist[b - 1][c - 1] = min( -                dist[b - 1][c - 1], dist[b - 1][a - 1] + dist[a - 1][c - 1] -            ) -# print("距離行列は以下") -# for i in range(n+1): -# print(dist[i]) +            dist[b][c] = min(dist[b][c], dist[b][a] + dist[a][c]) +# print(dist) -for p in itertools.permutations(ra): -    subt = 0 -    for i in range(r - 1): -        subt += dist[p[i] - 1][p[i + 1] - 1] -    if subt < ans: -        ans = subt +for v in itertools.permutations(city): +    cost = 0 +    for i in range(len(v) - 1): +        cost += dist[v[i] - 1][v[i + 1] - 1] +    # print(v,cost) +    ans = min(ans, cost)