import heapq

import itertools

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

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

d = [[float('inf')]*n for _ in range(n)]

for _ in range(m):

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

  a -= 1

  b -= 1

  d[a][b] = t

  d[b][a] = t

for i in range(n):

  d[i][i] = 0



def warshall_floyd(d):

  #d[i][j]: iからjへの最短距離

  for k in range(n):

    for i in range(n):

      for j in range(n):

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

  return d  



d = warshall_floyd(d)

ans = float('inf')

for v in itertools.permutations(r):

  tmp = 0

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

    tmp += d[v[i]][v[i+1]]

  ans = min(ans, tmp)



print(ans)

import itertools

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

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

graph = [[] for _ in range(N)]

d = [[float('inf')]*N for _ in range(N)]

for _ in range(M):

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

  a -= 1

  b -= 1

  graph[a] += [[b, c]]

  graph[b] += [[c, a]]

  d[a][b] = c

  d[b][a] = c



for i in range(N):

  d[i][i] = 0



def warshall_floyd(d):

  #d[i][j]: iからjへの最短距離

  for k in range(N):

    for i in range(N):

      for j in range(N):

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

  return d



d = warshall_floyd(d)

ans = float('inf')

for v in itertools.permutations(r):

  tmp = 0

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

    tmp += d[v[i]][v[i+1]]

  ans = min(ans, tmp)

print(ans)
import heapq
import itertools

n, m, r = list(map(int, input().split()))
r = list([int(x) - 1 for x in input().split()])
d = [[float("inf")] * n for _ in range(n)]
for _ in range(m):
    a, b, t = list(map(int, input().split()))
    a -= 1
    b -= 1
    d[a][b] = t
    d[b][a] = t
for i in range(n):
    d[i][i] = 0


def warshall_floyd(d):
    # d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


d = warshall_floyd(d)
ans = float("inf")
for v in itertools.permutations(r):
    tmp = 0
    for i in range(len(v) - 1):
        tmp += d[v[i]][v[i + 1]]
    ans = min(ans, tmp)
print(ans)

import itertools

N, M, R = list(map(int, input().split()))
r = list([int(x) - 1 for x in input().split()])
graph = [[] for _ in range(N)]
d = [[float("inf")] * N for _ in range(N)]
for _ in range(M):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    graph[a] += [[b, c]]
    graph[b] += [[c, a]]
    d[a][b] = c
    d[b][a] = c
for i in range(N):
    d[i][i] = 0


def warshall_floyd(d):
    # d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


d = warshall_floyd(d)
ans = float("inf")
for v in itertools.permutations(r):
    tmp = 0
    for i in range(len(v) - 1):
        tmp += d[v[i]][v[i + 1]]
    ans = min(ans, tmp)
print(ans)

-import heapq -n, m, r = list(map(int, input().split())) +N, M, R = list(map(int, input().split())) -d = [[float("inf")] * n for _ in range(n)] -for _ in range(m): -    a, b, t = list(map(int, input().split())) +graph = [[] for _ in range(N)] +d = [[float("inf")] * N for _ in range(N)] +for _ in range(M): +    a, b, c = list(map(int, input().split())) -    d[a][b] = t -    d[b][a] = t -for i in range(n): +    graph[a] += [[b, c]] +    graph[b] += [[c, a]] +    d[a][b] = c +    d[b][a] = c +for i in range(N): -    for k in range(n): -        for i in range(n): -            for j in range(n): +    for k in range(N): +        for i in range(N): +            for j in range(N):