N, M, K = (int(x) for x in input().split())

R = [int(x)-1 for x in input().split()]



dist = [[10e8 for _ in range(N)] for _ in range(N)]

for i in range(N): dist[i][i] = 0

for _ in range(M):

    a, b, c = (int(x) for x in input().split())

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

del a, b, c, K



for k in range(N):

    for i in range(N):

        for j in range(i,N):

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



def mindist(x, X):

    global dist

    Y = X.copy()

    Y.remove(x)

    if len(Y) == 0: return 0

    return min([dist[x][y] + mindist(y,Y) for y in Y])



ans = min([mindist(r, R) for r in R])

print(ans)
from itertools import permutations

import numpy as np

from scipy.sparse.csgraph import dijkstra



with open(0) as f:

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

    r = list(map(int, f.readline().split()))

    path = [tuple(map(int, line.split())) for line in f.readlines()]



graph = np.full((N,N), np.inf)

for a, b, c in path:

    graph[a-1, b-1] = c

    graph[b-1, a-1] = c



graph = dijkstra(graph, directed=False)

ans = np.inf

permutation = list(permutations(r))

for p in permutation:

    way = 0

    for x,y in zip(p[:len(r)], p[1:]):

        way += graph[x-1, y-1]

    ans = min(ans, way)

print((int(ans)))
N, M, K = (int(x) for x in input().split())
R = [int(x) - 1 for x in input().split()]
dist = [[10e8 for _ in range(N)] for _ in range(N)]
for i in range(N):
    dist[i][i] = 0
for _ in range(M):
    a, b, c = (int(x) for x in input().split())
    dist[a - 1][b - 1] = dist[b - 1][a - 1] = c
del a, b, c, K
for k in range(N):
    for i in range(N):
        for j in range(i, N):
            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k] + dist[k][j])


def mindist(x, X):
    global dist
    Y = X.copy()
    Y.remove(x)
    if len(Y) == 0:
        return 0
    return min([dist[x][y] + mindist(y, Y) for y in Y])


ans = min([mindist(r, R) for r in R])
print(ans)

from itertools import permutations
import numpy as np
from scipy.sparse.csgraph import dijkstra

with open(0) as f:
    N, M, R = list(map(int, f.readline().split()))
    r = list(map(int, f.readline().split()))
    path = [tuple(map(int, line.split())) for line in f.readlines()]
graph = np.full((N, N), np.inf)
for a, b, c in path:
    graph[a - 1, b - 1] = c
    graph[b - 1, a - 1] = c
graph = dijkstra(graph, directed=False)
ans = np.inf
permutation = list(permutations(r))
for p in permutation:
    way = 0
    for x, y in zip(p[: len(r)], p[1:]):
        way += graph[x - 1, y - 1]
    ans = min(ans, way)
print((int(ans)))

-N, M, K = (int(x) for x in input().split()) -R = [int(x) - 1 for x in input().split()] -dist = [[10e8 for _ in range(N)] for _ in range(N)] -for i in range(N): -    dist[i][i] = 0 -for _ in range(M): -    a, b, c = (int(x) for x in input().split()) -    dist[a - 1][b - 1] = dist[b - 1][a - 1] = c -del a, b, c, K -for k in range(N): -    for i in range(N): -        for j in range(i, N): -            dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k] + dist[k][j]) +from itertools import permutations +import numpy as np +from scipy.sparse.csgraph import dijkstra - -def mindist(x, X): -    global dist -    Y = X.copy() -    Y.remove(x) -    if len(Y) == 0: -        return 0 -    return min([dist[x][y] + mindist(y, Y) for y in Y]) - - -ans = min([mindist(r, R) for r in R]) -print(ans) +with open(0) as f: +    N, M, R = list(map(int, f.readline().split())) +    r = list(map(int, f.readline().split())) +    path = [tuple(map(int, line.split())) for line in f.readlines()] +graph = np.full((N, N), np.inf) +for a, b, c in path: +    graph[a - 1, b - 1] = c +    graph[b - 1, a - 1] = c +graph = dijkstra(graph, directed=False) +ans = np.inf +permutation = list(permutations(r)) +for p in permutation: +    way = 0 +    for x, y in zip(p[: len(r)], p[1:]): +        way += graph[x - 1, y - 1] +    ans = min(ans, way) +print((int(ans)))