# ABC073D - joisino's travel (210ms)

from heapq import heapify, heappop, heappush

from itertools import permutations





def dijkstra(source: int) -> list:

    dist = [float("inf")] * (N + 1)

    undetermined = N  # vertex_0 won't appear in 1-idx graph

    queue = [(0, source)]

    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))

        undetermined -= 1

        if not undetermined:

            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(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 heappop, heappush

from itertools import permutations





def dijkstra(source: int) -> "Array[int]":

    # compute the distance of the shortest path from V_source to each vertex

    size = len(G)

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

    dist[source] = 0

    undetermined = size - 2  # V_0 and V_source are determined in 1-idx graph

    queue = [(0, source)]

    while queue:

        cost, v = heappop(queue)

        if cost > dist[v]:

            continue

        for next_cost, u in G[v]:

            if cost + next_cost < dist[u]:

                dist[u] = cost + next_cost

                heappush(queue, (dist[u], u))

        undetermined -= 1

        if not undetermined:

            return dist

    return dist





def main():

    global G

    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(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 (210ms)
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(source: int) -> list:
    dist = [float("inf")] * (N + 1)
    undetermined = N  # vertex_0 won't appear in 1-idx graph
    queue = [(0, source)]
    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))
        undetermined -= 1
        if not undetermined:
            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(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 heappop, heappush
from itertools import permutations


def dijkstra(source: int) -> "Array[int]":
    # compute the distance of the shortest path from V_source to each vertex
    size = len(G)
    dist = [float("inf")] * size
    dist[source] = 0
    undetermined = size - 2  # V_0 and V_source are determined in 1-idx graph
    queue = [(0, source)]
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        for next_cost, u in G[v]:
            if cost + next_cost < dist[u]:
                dist[u] = cost + next_cost
                heappush(queue, (dist[u], u))
        undetermined -= 1
        if not undetermined:
            return dist
    return dist


def main():
    global G
    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(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 (210ms) -from heapq import heapify, heappop, heappush +# ABC073D - joisino's travel +from heapq import heappop, heappush -def dijkstra(source: int) -> list: -    dist = [float("inf")] * (N + 1) -    undetermined = N  # vertex_0 won't appear in 1-idx graph +def dijkstra(source: int) -> "Array[int]": +    # compute the distance of the shortest path from V_source to each vertex +    size = len(G) +    dist = [float("inf")] * size +    dist[source] = 0 +    undetermined = size - 2  # V_0 and V_source are determined in 1-idx graph -    heapify(queue) -        dist[v] = cost -                heappush(queue, (cost + next_cost, u)) +                dist[u] = cost + next_cost +                heappush(queue, (dist[u], u)) +    return dist -    global G, N +    global G