local n, m = io.read("*n", "*n")
local cost = {}
local parent = {}
for i = 1, n do
  cost[i] = io.read("*n")
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, m do
  local x, y = io.read("*n", "*n")
  x, y = x + 1, y + 1
  local xp, yp = uf_findroot(x), uf_findroot(y)
  parent[y], parent[yp] = xp, xp
end

local group = {}
for i = 1, n do
  local p = uf_findroot(i)
  if not group[p] then group[p] = {} end
  table.insert(group[p], cost[i])
end
local groupcnt = 0
local mincost = 0
local remcost = {}
for _k, cs in pairs(group) do
  groupcnt = groupcnt + 1
  table.sort(cs)
  mincost = mincost + cs[1]
  for i = 2, #cs do
    table.insert(remcost, cs[i])
  end
end
if groupcnt == 1 then
  print(0)
elseif (groupcnt - 1) * 2 <= n then
  table.sort(remcost)
  for i = 1, (groupcnt - 1) * 2 - groupcnt do
    mincost = mincost + remcost[i]
  end
  print(mincost)
else
  print("Impossible")
end
