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



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



import scipy.sparse as ss

import numpy as np



G = ss.dok_matrix((N,N), dtype=np.uint32)



def it():

  for _ in range(M):

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

    a -= 1

    b -= 1

    yield ((a,b),c)

    yield ((b,a),c)



G.update(it())



D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False)



def it2():

  from itertools import permutations

  for p in permutations(R):

    pp = iter(p)

    next(pp)

    yield sum(D[a,b] for a,b in zip(p,pp))



print((int(min(it2()))))
N,M,NR = list(map(int,input().split()))



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



import numpy as np

from scipy.sparse.csgraph import floyd_warshall



G = np.zeros((N,N))



for _ in range(M):

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

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



floyd_warshall(G, directed=False, overwrite=True)



def it2():

  from itertools import permutations

  for p in permutations(R):

    pp = iter(p)

    next(pp)

    yield sum(G[a,b] for a,b in zip(p,pp))



print((int(min(it2()))))
N, M, NR = list(map(int, input().split()))
R = list([int(x) - 1 for x in input().split()])
import scipy.sparse as ss
import numpy as np

G = ss.dok_matrix((N, N), dtype=np.uint32)


def it():
    for _ in range(M):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        yield ((a, b), c)
        yield ((b, a), c)


G.update(it())
D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False)


def it2():
    from itertools import permutations

    for p in permutations(R):
        pp = iter(p)
        next(pp)
        yield sum(D[a, b] for a, b in zip(p, pp))


print((int(min(it2()))))

N, M, NR = list(map(int, input().split()))
R = list([int(x) - 1 for x in input().split()])
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

G = np.zeros((N, N))
for _ in range(M):
    a, b, c = list(map(int, input().split()))
    G[a - 1, b - 1] = c
floyd_warshall(G, directed=False, overwrite=True)


def it2():
    from itertools import permutations

    for p in permutations(R):
        pp = iter(p)
        next(pp)
        yield sum(G[a, b] for a, b in zip(p, pp))


print((int(min(it2()))))

-import scipy.sparse as ss +from scipy.sparse.csgraph import floyd_warshall -G = ss.dok_matrix((N, N), dtype=np.uint32) - - -def it(): -    for _ in range(M): -        a, b, c = list(map(int, input().split())) -        a -= 1 -        b -= 1 -        yield ((a, b), c) -        yield ((b, a), c) - - -G.update(it()) -D = ss.csgraph.floyd_warshall(G.tocsr(), directed=False) +G = np.zeros((N, N)) +for _ in range(M): +    a, b, c = list(map(int, input().split())) +    G[a - 1, b - 1] = c +floyd_warshall(G, directed=False, overwrite=True) -        yield sum(D[a, b] for a, b in zip(p, pp)) +        yield sum(G[a, b] for a, b in zip(p, pp))