{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Control.Applicative
import Control.Monad.ST
import Control.Monad.State
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

buildGraph :: (Int,Int) -> [(Node,Node,Cost)] -> Graph
buildGraph bound dat = runST $ do
  graph <- newArray bound [] :: ST s (STArray s Int [Edge])
  forM_ dat $ \(s,e,c) -> do
    modifyArray graph s ((e,c):)
    modifyArray graph e ((s,c):)
  freeze graph
  
for = flip map

main :: IO ()
main = do
  (n,m,r) <- listToTuple3 . map read . words <$> getLine :: IO (Int,Int,Int)
  rs <- map read . words <$> getLine :: IO [Int]
  graph <- buildGraph (1,n) . map (listToTuple3 . map readIntBS . BS.words) . BS.lines <$> BS.getContents :: IO Graph
  let wf = warshall_floyd graph

  print $ minimum . for (permutations rs) $ \xs -> sum . for [1..r-1] $ \i -> wf!(xs!!(i-1),xs!!i)

type Node = Int
type Cost = Int
type Edge = (Node, Cost)
type Graph = Array Node [Edge]

inf = div maxBound 2 :: Int

warshall_floyd :: Graph -> Array (Node,Node) Cost
warshall_floyd graph = runST $ do
  let (s,e) = bounds graph
  dp <- newArray ((s,s),(e,e)) inf :: ST s (STUArray s (Node,Node) Cost)

  forM_ [s..e] $ \i -> do
    writeArray dp (i,i) 0

  forM_ [s..e] $ \i -> do
    forM_ (graph ! i) $ \(j,c) -> do
      writeArray dp (i,j) c

  forM_ [s..e] $ \k -> do
    forM_ [s..e] $ \i -> do
      forM_ [s..e] $ \j -> do
        a <- readArray dp (i,j)
        b <- readArray dp (i,k)
        c <- readArray dp (k,j)
        writeArray dp (i,j) $ min a (b+c)

  freeze dp
