let rec take n = function
  | [] -> []
  | x :: xs ->
      if n = 0 then []
      else x :: take (n - 1) xs

(* 配列版素集合データ構造 *)
module RawUnionFind : sig
  type t
  type class_

  (* n要素の素集合データ構造を作る *)
  val make : int -> t
  (* 要素がどの集合に属するか調べる *)
  (* 要素は0からn-1の整数である必要がある *)
  val find : t -> int -> class_
  (* 与えられた要素が属する集合同士を合併する *)
  val unite : t -> int -> int -> unit

  val compare_class : class_ -> class_ -> int
end = struct
  type t = { rank : int array; parent : int array }
  type class_ = int

  let make n =
    { rank = Array.make n 0;
      parent = Array.init n (fun c -> c) }

  let rec find uf x =
    if x = uf.parent.(x) then x
    else begin
      let y = find uf uf.parent.(x) in
      uf.parent.(x) <- y; y
    end

  let unite uf i j =
    let x = find uf i in
    let y = find uf j in
    if x <> y then begin
      if uf.rank.(x) < uf.rank.(y) then uf.parent.(x) <- y
      else begin
        uf.parent.(y) <- x;
        if uf.rank.(x) = uf.rank.(y) then
          uf.rank.(x) <- 1 + uf.rank.(x)
      end
    end

  let compare_class = compare
end

module ClassMap = Map.Make (struct
  type t = RawUnionFind.class_
  let compare = RawUnionFind.compare_class
end)

let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let uf = RawUnionFind.make n in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d\n" @@ RawUnionFind.unite uf
  done;
  let m = Array.fold_left (fun m i ->
    ClassMap.add (RawUnionFind.find uf i)
      (as_.(i) :: try ClassMap.find (RawUnionFind.find uf i) m with Not_found -> []) m) ClassMap.empty @@
    Array.init n @@ fun i -> i in
  if n < (ClassMap.cardinal m - 1) * 2 then print_endline "Impossible"
  else if ClassMap.cardinal m = 1 then print_endline "0"
  else
    ClassMap.fold (fun _ (a :: as_) (acc, rest) ->
      let (a, acc, rest) =
        List.fold_left (fun (a, acc, rest) a' ->
          if a <= a'
          then (a, acc, a' :: rest)
          else (a', acc, a :: rest)) (a, acc, rest) as_ in
      (a + acc, rest)) m (0, [])
    |> fun (acc, rest) ->
        Printf.printf "%d\n" @@
          List.fold_left ( + ) acc @@
            take (ClassMap.cardinal m - 2) @@
              List.sort compare rest
