import itertools

import sys 

input = sys.stdin.readline

def solve():

  n,m,R = (int(i) for i in input().split())

  r = list(int(i) for i in input().split())

  d = [[float("Inf")]*n for _ in range(n)]

  for i in range(m):

    a,b,c = (int(i) for i in input().split())

    d[a-1][b-1] = c

    d[b-1][a-1] = c

    

  for k in range(n):

    for i in range(n):

      for j in range(n):

        if d[i][j] > d[i][k] + d[k][j]:

          d[i][j] = d[i][k] + d[k][j]



  perm = list(itertools.permutations(list(range(R))))

  cost = float("Inf")

  

  for i in range(len(perm)):

    root = perm[i]

    tempcost = 0

    for j in range(R-1):

      na = r[root[j]]-1

      nb = r[root[j+1]]-1

      tempcost += d[na][nb]

    cost = min(tempcost,cost)

  print(cost)

solve()
import itertools

from scipy.sparse.csgraph import dijkstra

import sys 

input = sys.stdin.readline

def solve():

  n,m,R = (int(i) for i in input().split())

  r = list(int(i) for i in input().split())

  d = [[float("Inf")]*n for _ in range(n)]

  for i in range(m):

    a,b,c = (int(i) for i in input().split())

    d[a-1][b-1] = c

    d[b-1][a-1] = c

    

  d = dijkstra(d)



  perm = list(itertools.permutations(list(range(R))))

  cost = float("Inf")

  for i in range(len(perm)):

    root = perm[i]

    tempcost = 0

    for j in range(R-1):

      na = r[root[j]]-1

      nb = r[root[j+1]]-1

      tempcost += d[na][nb]

    cost = min(tempcost,cost)

  print((int(cost)))

solve()
import itertools
import sys

input = sys.stdin.readline


def solve():
    n, m, R = (int(i) for i in input().split())
    r = list(int(i) for i in input().split())
    d = [[float("Inf")] * n for _ in range(n)]
    for i in range(m):
        a, b, c = (int(i) for i in input().split())
        d[a - 1][b - 1] = c
        d[b - 1][a - 1] = c
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    perm = list(itertools.permutations(list(range(R))))
    cost = float("Inf")
    for i in range(len(perm)):
        root = perm[i]
        tempcost = 0
        for j in range(R - 1):
            na = r[root[j]] - 1
            nb = r[root[j + 1]] - 1
            tempcost += d[na][nb]
        cost = min(tempcost, cost)
    print(cost)


solve()

import itertools
from scipy.sparse.csgraph import dijkstra
import sys

input = sys.stdin.readline


def solve():
    n, m, R = (int(i) for i in input().split())
    r = list(int(i) for i in input().split())
    d = [[float("Inf")] * n for _ in range(n)]
    for i in range(m):
        a, b, c = (int(i) for i in input().split())
        d[a - 1][b - 1] = c
        d[b - 1][a - 1] = c
    d = dijkstra(d)
    perm = list(itertools.permutations(list(range(R))))
    cost = float("Inf")
    for i in range(len(perm)):
        root = perm[i]
        tempcost = 0
        for j in range(R - 1):
            na = r[root[j]] - 1
            nb = r[root[j + 1]] - 1
            tempcost += d[na][nb]
        cost = min(tempcost, cost)
    print((int(cost)))


solve()

+from scipy.sparse.csgraph import dijkstra -    for k in range(n): -        for i in range(n): -            for j in range(n): -                if d[i][j] > d[i][k] + d[k][j]: -                    d[i][j] = d[i][k] + d[k][j] +    d = dijkstra(d) -    print(cost) +    print((int(cost)))