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

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

# construct map

import numpy as np

dists = np.ones((n + 1, n + 1)) * float('inf')

for _ in range(m):

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

    dists[a, b] = dists[b, a] = c

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

    dists[i, i] = 0



from itertools import product, permutations

for i, j in product(list(range(1, 1 + n)), repeat=2):

    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])



ans = float('inf')

for path in permutations(rs):

    val = sum(dists[i, j] for i, j in zip(path, path[1:]))

    val = int(val)

    if val < ans:

        ans = val



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

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

# construct map

import numpy as np

dists = np.ones((n + 1, n + 1)) * float('inf')

for _ in range(m):

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

    dists[a, b] = dists[b, a] = c

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

    dists[i, i] = 0



from itertools import permutations

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

    dists = np.minimum(dists, dists[i: i + 1] + dists[:, i: i + 1])



ans = float('inf')

for path in permutations(rs):

    val = sum(dists[i, j] for i, j in zip(path, path[1:]))

    val = int(val)

    if val < ans:

        ans = val



print(ans)
n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np

dists = np.ones((n + 1, n + 1)) * float("inf")
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0
from itertools import product, permutations

for i, j in product(list(range(1, 1 + n)), repeat=2):
    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])
ans = float("inf")
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val
print(ans)

n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np

dists = np.ones((n + 1, n + 1)) * float("inf")
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0
from itertools import permutations

for i in range(1, 1 + n):
    dists = np.minimum(dists, dists[i : i + 1] + dists[:, i : i + 1])
ans = float("inf")
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val
print(ans)

-from itertools import product, permutations +from itertools import permutations -for i, j in product(list(range(1, 1 + n)), repeat=2): -    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i]) +for i in range(1, 1 + n): +    dists = np.minimum(dists, dists[i : i + 1] + dists[:, i : i + 1])