module WeightedDirectedGraph
  (Weight : sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  val warshall_floyd :
    (* 頂点のリスト *)
    'v list ->
    (* 辺のリスト *)
    ('v * 'v * Weight.t) list ->
    (* 辿り着けなければNoneを返す *)
    ('v -> 'v -> Weight.t option)
end =
struct
  let warshall_floyd vs es =
    (* 準備 *)
    (* dに入ってない2頂点の距離は無限とみなす *)
    let d =
      let n = List.length vs in
      Hashtbl.create (n * n) in
    List.iter (fun (u, v, c) ->
      Hashtbl.replace d (u, v) c) es;
    List.iter (fun v ->
      Hashtbl.replace d (v, v) Weight.zero) vs;
    (* メインループ *)
    List.iter (fun i ->
      List.iter (fun j ->
        List.iter (fun k ->
          (* d.(j).(k) <- min d.(j).(k) (d.(j).(i) + d.(i).(k)) *)
          let open Weight in
          match Hashtbl.find d (j, i) + Hashtbl.find d (i, k) with
          | exception Not_found -> () (* d.(j).(i) + d.(i).(k) は無限大 *)
          | djk' ->
              (* djk' = d.(j).(i) + d.(i).(k) *)
              if
                (* d.(j).(k) > d.(j).(i) + d.(i).(k) *)
                try 0 < compare (Hashtbl.find d (j, k)) djk'
                with Not_found -> true (* d.(j).(k) は無限大 *)
              then Hashtbl.replace d (j, k) djk') vs) vs) vs;
    fun u v -> try Some (Hashtbl.find d (u, v)) with Not_found -> None
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let compare = compare
end)

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 () =
  let n, m, r = Scanf.scanf "%d %d %d\n" (fun n m r -> n, m, r) in
  let rs = Array.to_list @@ Array.init r (fun _ -> Scanf.scanf "%d " (fun r -> r - 1)) in
  let abcs = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf "%d %d %d\n" (fun a b c -> a - 1, b - 1, c)) in
  let d =
    G.warshall_floyd (Array.to_list @@ Array.init n (fun i -> i)) @@
      List.rev_append (List.rev_map (fun (a, b, c) -> (b, a, c)) abcs) abcs in
  permutation rs
  |> List.map (fun (r :: rs) ->
      List.fold_left (fun (r, a) s -> (s, (r, s) :: a)) (r, []) rs
      |> snd
      |> List.map (fun (r, s) ->
          match d r s with
          | None -> max_int
          | Some d -> d)
      |> List.fold_left ( + ) 0)
  |> List.fold_left min max_int
  |> Printf.printf "%d\n"