let rec select acc trace = function
  | [] -> acc
  | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs
let select xs = select [] [] xs

let rec permutation = function
  | [] -> [[]]
  | xs -> 
      List.concat @@ List.map (fun (xs, x, ys) -> List.map (fun xs -> x :: xs) (permutation (List.rev_append xs ys)))
      (select xs)

let warshall_floyd ( + ) min n d =
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      for k = 0 to n - 1 do
        d.(j).(k) <- min d.(j).(k) (d.(j).(i) + d.(i).(k))
      done
    done
  done

let () =
  let n, m, r = Scanf.scanf "%d %d %d\n" (fun n m r -> n, m, r) in
  let rs = Array.init r (fun _ -> Scanf.scanf "%d " (fun r -> r - 1)) in
  let abcs = Array.init m (fun _ -> Scanf.scanf "%d %d %d\n" (fun a b c -> a - 1, b - 1, c)) in
  let d = Array.make_matrix n n 10000000 in
  for i = 0 to n - 1 do
    d.(i).(i) <- 0
  done;
  Array.iter (fun (a, b, c) ->
    d.(a).(b) <- c;
    d.(b).(a) <- c) abcs;
  warshall_floyd ( + ) min n d;
  (Array.to_list rs
  |> permutation
  |> List.map (fun (r :: rs) ->
      List.fold_left (fun (r, a) s -> (s, (r, s) :: a)) (r, []) rs
      |> snd
      |> List.map (fun (r, s) -> d.(r).(s))
      |> List.fold_left ( + ) 0)
  |> List.fold_left min max_int
  |> Printf.printf "%d\n")