from itertools import*

from scipy.sparse.csgraph import floyd_warshall

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

*R,=list(map(int,input().split()))



table=[[0]*n for i in range(n)]

for i in range(m):

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

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

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

d,p=floyd_warshall(csgraph=table, directed=False, return_predecessors=True)

cost=[sum(d[i[j]-1][i[j+1]-1]for j in range(r-1))for i in permutations(R)]

print((int(min(cost))))
#from numpy import*

#from scipy import*

from collections import* #defaultdict Counter deque appendleft

from fractions import gcd

from functools import* #reduce

from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby

from operator import mul

from bisect import* #bisect_left bisect_right

from heapq import* #heapify heappop heappushpop

from math import factorial

from copy import deepcopy

import sys

from scipy.sparse.csgraph import floyd_warshall



#input=sys.stdin.readline  #危険！基本オフにしろ！

sys.setrecursionlimit(10**6)





def main():

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

    grid=[[0]*n for i in range(n)]

    *R,=list(map(int,input().split()))

    for i in range(m):

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

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

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

#    print(grid)

    d,p=floyd_warshall(csgraph=grid, directed=False, return_predecessors=True)

#    print(p)

#    print(d)

    print((int(min(sum(d[i[j]-1][i[j+1]-1]for j in range(len(i)-1))for i in permutations(R)))))

    

if __name__ == '__main__':

    main()

from itertools import *
from scipy.sparse.csgraph import floyd_warshall

n, m, r = list(map(int, input().split()))
(*R,) = list(map(int, input().split()))
table = [[0] * n for i in range(n)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    table[a - 1][b - 1] = c
    table[b - 1][a - 1] = c
d, p = floyd_warshall(csgraph=table, directed=False, return_predecessors=True)
cost = [sum(d[i[j] - 1][i[j + 1] - 1] for j in range(r - 1)) for i in permutations(R)]
print((int(min(cost))))

# from numpy import*
# from scipy import*
from collections import *  # defaultdict Counter deque appendleft
from fractions import gcd
from functools import *  # reduce
from itertools import *  # permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby
from operator import mul
from bisect import *  # bisect_left bisect_right
from heapq import *  # heapify heappop heappushpop
from math import factorial
from copy import deepcopy
import sys
from scipy.sparse.csgraph import floyd_warshall

# input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)


def main():
    n, m, r = list(map(int, input().split()))
    grid = [[0] * n for i in range(n)]
    (*R,) = list(map(int, input().split()))
    for i in range(m):
        a, b, c = list(map(int, input().split()))
        grid[a - 1][b - 1] = c
        grid[b - 1][a - 1] = c
    #    print(grid)
    d, p = floyd_warshall(csgraph=grid, directed=False, return_predecessors=True)
    #    print(p)
    #    print(d)
    print(
        (
            int(
                min(
                    sum(d[i[j] - 1][i[j + 1] - 1] for j in range(len(i) - 1))
                    for i in permutations(R)
                )
            )
        )
    )


if __name__ == "__main__":
    main()

-from itertools import * +# from numpy import* +# from scipy import* +from collections import *  # defaultdict Counter deque appendleft +from fractions import gcd +from functools import *  # reduce +from itertools import *  # permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby +from operator import mul +from bisect import *  # bisect_left bisect_right +from heapq import *  # heapify heappop heappushpop +from math import factorial +from copy import deepcopy +import sys -n, m, r = list(map(int, input().split())) -(*R,) = list(map(int, input().split())) -table = [[0] * n for i in range(n)] -for i in range(m): -    a, b, c = list(map(int, input().split())) -    table[a - 1][b - 1] = c -    table[b - 1][a - 1] = c -d, p = floyd_warshall(csgraph=table, directed=False, return_predecessors=True) -cost = [sum(d[i[j] - 1][i[j + 1] - 1] for j in range(r - 1)) for i in permutations(R)] -print((int(min(cost)))) +# input=sys.stdin.readline  #危険！基本オフにしろ！ +sys.setrecursionlimit(10**6) + + +def main(): +    n, m, r = list(map(int, input().split())) +    grid = [[0] * n for i in range(n)] +    (*R,) = list(map(int, input().split())) +    for i in range(m): +        a, b, c = list(map(int, input().split())) +        grid[a - 1][b - 1] = c +        grid[b - 1][a - 1] = c +    #    print(grid) +    d, p = floyd_warshall(csgraph=grid, directed=False, return_predecessors=True) +    #    print(p) +    #    print(d) +    print( +        ( +            int( +                min( +                    sum(d[i[j] - 1][i[j + 1] - 1] for j in range(len(i) - 1)) +                    for i in permutations(R) +                ) +            ) +        ) +    ) + + +if __name__ == "__main__": +    main()