from itertools import permutations

INF=10**18

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

dist=[[INF for _ in range(n+1)]for _ in range(n+1)]

dp=[[-1 for _ in range(r+1)]for _ in  range((1<<r)+1)]

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

for i in range(n+1):

  dist[i][i]=0

for _ in range(m):

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

  dist[a][b]=c

  dist[b][a]=c

for k in range(n+1):

  for i in range(n+1):

    for j in range(n+1):

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

r_list=list(permutations(r_t))

fans=INF

for i in r_list:

  ans=0

  for j in range(r-1):

    ans+=dist[i[j+1]][i[j]]

  fans=min(fans,ans)

print(fans)
from itertools import*

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

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

INF=10**18

d=[[INF]*n for _ in range(n)]

for _ in range(m):

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

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

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

for k in range(n):

  for i in range(n):

    for j in range(n):

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

ans=INF

for i in permutations(rc):

  a=0

  i=list(i)

  for j in range(r-1):

    a+=d[i[j]-1][i[j+1]-1]

  ans=min(a,ans)

print(ans)
from itertools import permutations

INF = 10**18
n, m, r = list(map(int, input().split()))
dist = [[INF for _ in range(n + 1)] for _ in range(n + 1)]
dp = [[-1 for _ in range(r + 1)] for _ in range((1 << r) + 1)]
r_t = list(map(int, input().split()))
for i in range(n + 1):
    dist[i][i] = 0
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dist[a][b] = c
    dist[b][a] = c
for k in range(n + 1):
    for i in range(n + 1):
        for j in range(n + 1):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
r_list = list(permutations(r_t))
fans = INF
for i in r_list:
    ans = 0
    for j in range(r - 1):
        ans += dist[i[j + 1]][i[j]]
    fans = min(fans, ans)
print(fans)

from itertools import *

n, m, r = list(map(int, input().split()))
rc = list(map(int, input().split()))
INF = 10**18
d = [[INF] * n for _ in range(n)]
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = INF
for i in permutations(rc):
    a = 0
    i = list(i)
    for j in range(r - 1):
        a += d[i[j] - 1][i[j + 1] - 1]
    ans = min(a, ans)
print(ans)

-from itertools import permutations +from itertools import * +n, m, r = list(map(int, input().split())) +rc = list(map(int, input().split())) -n, m, r = list(map(int, input().split())) -dist = [[INF for _ in range(n + 1)] for _ in range(n + 1)] -dp = [[-1 for _ in range(r + 1)] for _ in range((1 << r) + 1)] -r_t = list(map(int, input().split())) -for i in range(n + 1): -    dist[i][i] = 0 +d = [[INF] * n for _ in range(n)] -    dist[a][b] = c -    dist[b][a] = c -for k in range(n + 1): -    for i in range(n + 1): -        for j in range(n + 1): -            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) -r_list = list(permutations(r_t)) -fans = INF -for i in r_list: -    ans = 0 +    d[a - 1][b - 1] = c +    d[b - 1][a - 1] = c +for k in range(n): +    for i in range(n): +        for j in range(n): +            d[i][j] = min(d[i][j], d[i][k] + d[k][j]) +ans = INF +for i in permutations(rc): +    a = 0 +    i = list(i) -        ans += dist[i[j + 1]][i[j]] -    fans = min(fans, ans) -print(fans) +        a += d[i[j] - 1][i[j + 1] - 1] +    ans = min(a, ans) +print(ans)