from itertools import permutations



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

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



INF = float('inf')

graph = [[INF for i in range(N)] for j in range(N)]

for i in range(M):

    A, B, C = list(map(int, input().split()))

    graph[A-1][B-1] = C

    graph[B-1][A-1] = C



for i in range(N):

    graph[i][i] = 0



for k in range(N):

    for i in range(N):

        for j in range(N):

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

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



ans = 10**9

for p in permutations(r, len(r)):

    dist = 0

    flag = 0

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

        if graph[p[i]-1][p[i+1]-1] == INF:

            flag = 1

            continue

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

    if flag == 0:

        ans = min(ans, dist)



print(ans)
from itertools import permutations



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

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



INF = float('inf')

graph = [[INF for i in range(N)] for j in range(N)]

for i in range(M):

    A, B, C = list(map(int, input().split()))

    graph[A-1][B-1] = C

    graph[B-1][A-1] = C



for i in range(N):

    graph[i][i] = 0



for k in range(N):

    for i in range(N):

        for j in range(N):

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



ans = 10**9

for p in permutations(r, len(r)):

    dist = 0

    flag = 0

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

        if graph[p[i]-1][p[i+1]-1] == INF:

            flag = 1

            continue

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

    if flag == 0:

        ans = min(ans, dist)



print(ans)
from itertools import permutations

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
INF = float("inf")
graph = [[INF for i in range(N)] for j in range(N)]
for i in range(M):
    A, B, C = list(map(int, input().split()))
    graph[A - 1][B - 1] = C
    graph[B - 1][A - 1] = C
for i in range(N):
    graph[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
            graph[j][i] = min(graph[j][i], graph[j][k] + graph[k][i])
ans = 10**9
for p in permutations(r, len(r)):
    dist = 0
    flag = 0
    for i in range(len(r) - 1):
        if graph[p[i] - 1][p[i + 1] - 1] == INF:
            flag = 1
            continue
        dist += graph[p[i] - 1][p[i + 1] - 1]
    if flag == 0:
        ans = min(ans, dist)
print(ans)

from itertools import permutations

N, M, R = list(map(int, input().split()))
r = list(map(int, input().split()))
INF = float("inf")
graph = [[INF for i in range(N)] for j in range(N)]
for i in range(M):
    A, B, C = list(map(int, input().split()))
    graph[A - 1][B - 1] = C
    graph[B - 1][A - 1] = C
for i in range(N):
    graph[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
ans = 10**9
for p in permutations(r, len(r)):
    dist = 0
    flag = 0
    for i in range(len(r) - 1):
        if graph[p[i] - 1][p[i + 1] - 1] == INF:
            flag = 1
            continue
        dist += graph[p[i] - 1][p[i + 1] - 1]
    if flag == 0:
        ans = min(ans, dist)
print(ans)

-            graph[j][i] = min(graph[j][i], graph[j][k] + graph[k][i])