# ABC073D - joisino's travel

from heapq import heapify, heappop, heappush

from itertools import permutations





def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:

    dist = [float("inf")] * size

    queue = [(start, 0)]

    heapify(queue)

    while queue:

        v, cost = heappop(queue)

        if cost > dist[v]:

            continue

        dist[v] = cost

        for u, next_cost in G[v]:

            if cost + next_cost < dist[u]:

                heappush(queue, (u, cost + next_cost))

    return dist





def main():

    global G, N

    N, M, R, *RABC = list(map(int, open(0).read().split()))

    visit, ABC = RABC[:R], RABC[R:]

    G = [[] for _ in range(N + 1)]

    for v, u, c in zip(*[iter(ABC)] * 3):

        G[v].append((u, c)), G[u].append((v, c))

    dist = {v: dijkstra(G, N + 1, v) for v in visit}

    ans = float("inf")

    for perm in permutations(visit):

        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))

        ans = min(ans, cur)

    print(ans)





if __name__ == "__main__":

    main()
# ABC073D - joisino's travel

from heapq import heapify, heappop, heappush

from itertools import permutations





def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:

    dist = [float("inf")] * size

    queue = [(0, start)]

    heapify(queue)

    while queue:

        cost, v = heappop(queue)

        if cost > dist[v]:

            continue

        dist[v] = cost

        for u, next_cost in G[v]:

            if cost + next_cost < dist[u]:

                heappush(queue, (cost + next_cost, u))

    return dist





def main():

    global G, N

    N, M, R, *RABC = list(map(int, open(0).read().split()))

    visit, ABC = RABC[:R], RABC[R:]

    G = [[] for _ in range(N + 1)]

    for v, u, c in zip(*[iter(ABC)] * 3):

        G[v].append((u, c)), G[u].append((v, c))

    dist = {v: dijkstra(G, N + 1, v) for v in visit}

    ans = float("inf")

    for perm in permutations(visit):

        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))

        ans = min(ans, cur)

    print(ans)





if __name__ == "__main__":

    main()
# ABC073D - joisino's travel
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
    dist = [float("inf")] * size
    queue = [(start, 0)]
    heapify(queue)
    while queue:
        v, cost = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for u, next_cost in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (u, cost + next_cost))
    return dist


def main():
    global G, N
    N, M, R, *RABC = list(map(int, open(0).read().split()))
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, c in zip(*[iter(ABC)] * 3):
        G[v].append((u, c)), G[u].append((v, c))
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

# ABC073D - joisino's travel
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
    dist = [float("inf")] * size
    queue = [(0, start)]
    heapify(queue)
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for u, next_cost in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (cost + next_cost, u))
    return dist


def main():
    global G, N
    N, M, R, *RABC = list(map(int, open(0).read().split()))
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, c in zip(*[iter(ABC)] * 3):
        G[v].append((u, c)), G[u].append((v, c))
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

-    queue = [(start, 0)] +    queue = [(0, start)] -        v, cost = heappop(queue) +        cost, v = heappop(queue) -                heappush(queue, (u, cost + next_cost)) +                heappush(queue, (cost + next_cost, u))