from itertools import permutations

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

INF = 1 << 60



d = [[INF] * n for i in range(n)]

rs = list(map(int, input().split()))



for i in range(m):

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

    a -= 1

    b -= 1

    d[a][b] = c

    d[b][a] = c



def warshall_floyd(d):

    """

    input

        d : 初期全点対距離

    output

        d : 最適化後全点対距離

    """

    n = len(d)

    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_optimized = warshall_floyd(d)

# print(d_optimized)



ans = INF

for inds in permutations([r-1 for r in rs]):

    cnt = 0

    for i in range(r-1):

        prev = inds[i]

        nxt = inds[i+1]

        cnt += d_optimized[prev][nxt]

    ans = min(ans,cnt)

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

INF = 1 << 40

edges = [[INF]*n for i in range(n)]

rs  = list(map(int, input().split()))

rs = [r-1 for r in rs]

for i in range(m):

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

    a -= 1

    b -= 1

    edges[a][b] = c

    edges[b][a] = c



for k in range(n):

    for i in range(n):

        for j in range(n):

            tmp = edges[i][k] + edges[k][j]

            edges[i][j] = min(edges[i][j], tmp)



from itertools import permutations



ans = 1 << 50

for perm in permutations(rs):

    dist = 0

    for i in range(1,len(perm)):

        f = perm[i-1]

        t = perm[i]

        dist += edges[f][t]

    ans = min(ans, dist)

print(ans)
from itertools import permutations

n, m, r = list(map(int, input().split()))
INF = 1 << 60
d = [[INF] * n for i in range(n)]
rs = list(map(int, input().split()))
for i in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c


def warshall_floyd(d):
    """
    input
        d : 初期全点対距離
    output
        d : 最適化後全点対距離
    """
    n = len(d)
    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_optimized = warshall_floyd(d)
# print(d_optimized)
ans = INF
for inds in permutations([r - 1 for r in rs]):
    cnt = 0
    for i in range(r - 1):
        prev = inds[i]
        nxt = inds[i + 1]
        cnt += d_optimized[prev][nxt]
    ans = min(ans, cnt)
print(ans)

n, m, r = list(map(int, input().split()))
INF = 1 << 40
edges = [[INF] * n for i in range(n)]
rs = list(map(int, input().split()))
rs = [r - 1 for r in rs]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    edges[a][b] = c
    edges[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            tmp = edges[i][k] + edges[k][j]
            edges[i][j] = min(edges[i][j], tmp)
from itertools import permutations

ans = 1 << 50
for perm in permutations(rs):
    dist = 0
    for i in range(1, len(perm)):
        f = perm[i - 1]
        t = perm[i]
        dist += edges[f][t]
    ans = min(ans, dist)
print(ans)

-from itertools import permutations - -INF = 1 << 60 -d = [[INF] * n for i in range(n)] +INF = 1 << 40 +edges = [[INF] * n for i in range(n)] +rs = [r - 1 for r in rs] -    d[a][b] = c -    d[b][a] = c +    edges[a][b] = c +    edges[b][a] = c +for k in range(n): +    for i in range(n): +        for j in range(n): +            tmp = edges[i][k] + edges[k][j] +            edges[i][j] = min(edges[i][j], tmp) +from itertools import permutations - -def warshall_floyd(d): -    """ -    input -        d : 初期全点対距離 -    output -        d : 最適化後全点対距離 -    """ -    n = len(d) -    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_optimized = warshall_floyd(d) -# print(d_optimized) -ans = INF -for inds in permutations([r - 1 for r in rs]): -    cnt = 0 -    for i in range(r - 1): -        prev = inds[i] -        nxt = inds[i + 1] -        cnt += d_optimized[prev][nxt] -    ans = min(ans, cnt) +ans = 1 << 50 +for perm in permutations(rs): +    dist = 0 +    for i in range(1, len(perm)): +        f = perm[i - 1] +        t = perm[i] +        dist += edges[f][t] +    ans = min(ans, dist)