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



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

e_list = [[] for i in range(N)]

for i in range(M):

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

    a=a-1

    b=b-1

    e_list[a].append([b,c])

    e_list[b].append([a,c])



#dijkstra

#you need to prepare e_list = [[orient,dist]]



import heapq

r_dis_list = []

for i in range(len(r)):

    vi = r[i]-1

    min_d_list = [10**27 for i in range(N)]

    min_d_list[vi] = 0

    prev_list = [-1 for i in range(N)]

    q = []

    for i in range(N):

        heapq.heappush(q,[min_d_list[i],i])



    while len(q)>0:

        d,v = heapq.heappop(q)

        for e in e_list[v]:

            v1,d1=e

            if min_d_list[v1]>d+d1:

                min_d_list[v1]=d+d1

                prev_list[v1]=v

                heapq.heappush(q,[d+d1,v1])



    r_dis_list.append([min_d_list[r[i]-1] for i in range(len(r))])



import itertools

min_ans = 10**27

for i in itertools.permutations(list(range(len(r)))):

    ans = 0

    for j in range(len(r)-1):

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

    min_ans=min(ans,min_ans)



print(min_ans)


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



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



e_list = [[] for i in range(N)]



for i in range(M):

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

    e_list[a-1].append((b-1,c))

    e_list[b-1].append((a-1,c))



#dijkstra

#you need to prepare e_list = [[orient,dist]]



import heapq



def dijkstra(vi):



    min_d_list = [10**27 for i in range(N)]

    min_d_list[vi] = 0

    q = []

    for i in range(N):

        heapq.heappush(q,[min_d_list[i],i])



    while len(q)>0:

        d,v = heapq.heappop(q)

        for e in e_list[v]:

            v1,d1=e

            if min_d_list[v1]>d+d1:

                min_d_list[v1]=d+d1

                heapq.heappush(q,[d+d1,v1])



    return min_d_list



D = [[0]*R for i in range(R)]

for i in range(R):

    min_d_list = dijkstra(r[i]-1)

    for j in range(R):

        D[i][j] = min_d_list[r[j]-1]



import itertools

min_ans=10**27

for v in itertools.permutations(list(range(R))):

    ans = 0

    for i in range(1,R):

        ans+=D[v[i]][v[i-1]]



    min_ans=min(min_ans,ans)



print(min_ans)
N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
e_list = [[] for i in range(N)]
for i in range(M):
    a, b, c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    e_list[a].append([b, c])
    e_list[b].append([a, c])
# dijkstra
# you need to prepare e_list = [[orient,dist]]
import heapq

r_dis_list = []
for i in range(len(r)):
    vi = r[i] - 1
    min_d_list = [10**27 for i in range(N)]
    min_d_list[vi] = 0
    prev_list = [-1 for i in range(N)]
    q = []
    for i in range(N):
        heapq.heappush(q, [min_d_list[i], i])
    while len(q) > 0:
        d, v = heapq.heappop(q)
        for e in e_list[v]:
            v1, d1 = e
            if min_d_list[v1] > d + d1:
                min_d_list[v1] = d + d1
                prev_list[v1] = v
                heapq.heappush(q, [d + d1, v1])
    r_dis_list.append([min_d_list[r[i] - 1] for i in range(len(r))])
import itertools

min_ans = 10**27
for i in itertools.permutations(list(range(len(r)))):
    ans = 0
    for j in range(len(r) - 1):
        ans += r_dis_list[i[j + 1]][i[j]]
    min_ans = min(ans, min_ans)
print(min_ans)

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
e_list = [[] for i in range(N)]
for i in range(M):
    a, b, c = list(map(int, input().split()))
    e_list[a - 1].append((b - 1, c))
    e_list[b - 1].append((a - 1, c))
# dijkstra
# you need to prepare e_list = [[orient,dist]]
import heapq


def dijkstra(vi):
    min_d_list = [10**27 for i in range(N)]
    min_d_list[vi] = 0
    q = []
    for i in range(N):
        heapq.heappush(q, [min_d_list[i], i])
    while len(q) > 0:
        d, v = heapq.heappop(q)
        for e in e_list[v]:
            v1, d1 = e
            if min_d_list[v1] > d + d1:
                min_d_list[v1] = d + d1
                heapq.heappush(q, [d + d1, v1])
    return min_d_list


D = [[0] * R for i in range(R)]
for i in range(R):
    min_d_list = dijkstra(r[i] - 1)
    for j in range(R):
        D[i][j] = min_d_list[r[j] - 1]
import itertools

min_ans = 10**27
for v in itertools.permutations(list(range(R))):
    ans = 0
    for i in range(1, R):
        ans += D[v[i]][v[i - 1]]
    min_ans = min(min_ans, ans)
print(min_ans)

-    a = a - 1 -    b = b - 1 -    e_list[a].append([b, c]) -    e_list[b].append([a, c]) +    e_list[a - 1].append((b - 1, c)) +    e_list[b - 1].append((a - 1, c)) -r_dis_list = [] -for i in range(len(r)): -    vi = r[i] - 1 + +def dijkstra(vi): -    prev_list = [-1 for i in range(N)] -                prev_list[v1] = v -    r_dis_list.append([min_d_list[r[i] - 1] for i in range(len(r))]) +    return min_d_list + + +D = [[0] * R for i in range(R)] +for i in range(R): +    min_d_list = dijkstra(r[i] - 1) +    for j in range(R): +        D[i][j] = min_d_list[r[j] - 1] -for i in itertools.permutations(list(range(len(r)))): +for v in itertools.permutations(list(range(R))): -    for j in range(len(r) - 1): -        ans += r_dis_list[i[j + 1]][i[j]] -    min_ans = min(ans, min_ans) +    for i in range(1, R): +        ans += D[v[i]][v[i - 1]] +    min_ans = min(min_ans, ans)