# ABC073D - joisino's travel (218ms)

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 next_cost, u 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, cost in zip(*[iter(ABC)] * 3):

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

    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 (218ms)

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

    unchecked = size - 1  # vertex_0 won't appear in 1-idx graph

    queue = [(0, start)]

    heapify(queue)

    while queue:

        cost, v = heappop(queue)

        if cost > dist[v]:

            continue

        dist[v] = cost

        for next_cost, u in G[v]:

            if cost + next_cost < dist[u]:

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

        unchecked -= 1

        if not unchecked:

            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, cost in zip(*[iter(ABC)] * 3):

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

    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 (218ms)
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 next_cost, u 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, cost in zip(*[iter(ABC)] * 3):
        G[v].append((cost, u)), G[u].append((cost, v))
    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 (218ms)
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
    unchecked = size - 1  # vertex_0 won't appear in 1-idx graph
    queue = [(0, start)]
    heapify(queue)
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for next_cost, u in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (cost + next_cost, u))
        unchecked -= 1
        if not unchecked:
            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, cost in zip(*[iter(ABC)] * 3):
        G[v].append((cost, u)), G[u].append((cost, v))
    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()

+    unchecked = size - 1  # vertex_0 won't appear in 1-idx graph -    return dist +        unchecked -= 1 +        if not unchecked: +            return dist