import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import qualified Data.Array.IArray as A
import qualified Data.Map.Strict as M
import Data.List

main = do
  [n,m,r] <- map read . words <$> getLine
  rs <- map (pred . read) . words <$> getLine
  es <- readUndirectedEdge <$> B.getContents
  let g = buildG (0,n-1) es
  let memo = warshallFloyd n es
  let vs = [(v,w) | v<-rs, w<-rs, v<w]
  print $ sum $ (\xs -> if length xs <= 2 then xs else init xs) $ sort $ map (\e -> memo M.! e) vs

type Memo = M.Map (Vertex, Vertex) Weight

-- 0-indexed vertex
warshallFloyd :: Int -> [Edge] -> Memo
warshallFloyd n es = foldl shorten m0 kij
  where
    m0 = M.fromList es
    kij = [(k, i, j) | k <- [0 .. pred n], i <- [0 .. pred n], j <- [0 .. pred n], i<j]

shorten :: Memo -> (Vertex, Vertex, Vertex) -> Memo
shorten m (k, i, j) = case connect m k i j of
  Nothing -> m
  Just w -> M.insertWith min (i, j) w m

connect :: Memo -> Vertex -> Vertex -> Vertex -> Maybe Weight
connect m k i j = do
  w1 <- M.lookup (i, k) m
  w2 <- M.lookup (k, j) m
  return (w1 + w2)

readInt :: B.ByteString -> Int
readInt = maybe undefined fst . B.readInt

type Bound = (Vertex, Vertex)
type Vertex = Int
type Weight = Int
type Edge = ((Vertex, Vertex), Weight)
type Path = [Vertex]
type Graph = A.Array Vertex (S.Set (Vertex, Weight))

buildG :: Bound -> [Edge] -> Graph
buildG b = A.accumArray (flip S.insert) S.empty b . map (\((s, t), w) -> (s, (t, w)))

target :: Graph -> Vertex -> S.Set (Vertex, Weight)
target = (A.!)

size :: Graph -> Int
size g = let (i,j) = A.bounds g in j - i + 1

readUndirectedEdge :: B.ByteString -> [Edge]
readUndirectedEdge = concatMap (constructTwoWay . map readInt . B.words) . B.lines

constructTwoWay :: [Int] -> [Edge]
constructTwoWay [s,t,w] = [((s-1, t-1), w), ((t-1, s-1), w)]
constructTwoWay _ = undefined