import sys

input = sys.stdin.buffer.readline

from collections import defaultdict

import heapq



def main():

    N,M = list(map(int,input().split()))

    a = list(map(int,input().split()))

    d = defaultdict(list)

        

    I = [i for i in range(N)]

    rank = [1 for _ in range(N)]

    def root(a):

        if I[a] == a:

            return a

        else:

            I[a] = root(I[a])

            return I[a]

            

    def unite(a,b):

        pa,pb = root(a),root(b)

        ra,rb = rank[a],rank[b]

        if ra > rb:

            I[pb] = pa

        else:

            I[pa] = pb

            if ra == rb:

                rank[pb] += 1

    

    for _ in range(M):

        x,y = list(map(int,input().split()))

        unite(x,y)

        parent = root(x)

    

    for i,num in enumerate(I):

        parent = root(num)

        heapq.heappush(d[parent],a[i])

        

    if M == N-1:

        print((0))

        exit()

    elif N < 2*(N-M-1):

        print("Impossible")

        exit()



    l = len(list(d.keys()))

    ans = 0

    rest = []

    for use in list(d.values()):

        ans += heapq.heappop(use)

        rest.extend(use)



    remain = 2*(N-M-1)-l

    rest.sort()

    ans += sum(rest[:remain])

    

    print(ans)

    

if __name__ == "__main__":

    main()

class UnionFind:

  def __init__(self, n):

    self.par = [i for i in range(n)]

    self.rank = [0]*n

  def find(self, x):

    if self.par[x]==x:

      return x

    else:

      self.par[x] = self.find(self.par[x])

      return self.par[x]

  def unit(self, x, y):

    x = self.find(x)

    y = self.find(y)

    if x==y:

      return

    elif self.rank[x]<self.rank[y]:

      self.par[x] = y

    elif self.rank[y]<self.rank[x]:

      self.par[y] = x

    else:

      self.par[y] = x

      self.rank[x] += 1

      

  def same(self, x, y):

    return self.find(x)==self.find(y)



from collections import defaultdict

N,M,*L = list(map(int, open(0).read().split()))

A = L[:N]

U = UnionFind(N)

for x,y in zip(*[iter(L[N:])]*2):

  U.unit(x,y)

ans = 0

rest = []

dic = defaultdict(list)

for i in range(N):

  dic[U.find(i)].append(A[i])

for k in list(dic.keys()):

  dic[k].sort()

  ans += dic[k][0]

  rest.extend(dic[k][1:])

if N-1==M:

  print((0))

  exit()

if N<2*(N-M-1):

  print('Impossible')

  exit()



rest.sort()

remain = 2*(N-M-1)-len(list(dic.keys()))

ans += sum(rest[:remain])

print(ans)

import sys

input = sys.stdin.buffer.readline
from collections import defaultdict
import heapq


def main():
    N, M = list(map(int, input().split()))
    a = list(map(int, input().split()))
    d = defaultdict(list)
    I = [i for i in range(N)]
    rank = [1 for _ in range(N)]

    def root(a):
        if I[a] == a:
            return a
        else:
            I[a] = root(I[a])
            return I[a]

    def unite(a, b):
        pa, pb = root(a), root(b)
        ra, rb = rank[a], rank[b]
        if ra > rb:
            I[pb] = pa
        else:
            I[pa] = pb
            if ra == rb:
                rank[pb] += 1

    for _ in range(M):
        x, y = list(map(int, input().split()))
        unite(x, y)
        parent = root(x)
    for i, num in enumerate(I):
        parent = root(num)
        heapq.heappush(d[parent], a[i])
    if M == N - 1:
        print((0))
        exit()
    elif N < 2 * (N - M - 1):
        print("Impossible")
        exit()
    l = len(list(d.keys()))
    ans = 0
    rest = []
    for use in list(d.values()):
        ans += heapq.heappop(use)
        rest.extend(use)
    remain = 2 * (N - M - 1) - l
    rest.sort()
    ans += sum(rest[:remain])
    print(ans)


if __name__ == "__main__":
    main()

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unit(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
        elif self.rank[y] < self.rank[x]:
            self.par[y] = x
        else:
            self.par[y] = x
            self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


from collections import defaultdict

N, M, *L = list(map(int, open(0).read().split()))
A = L[:N]
U = UnionFind(N)
for x, y in zip(*[iter(L[N:])] * 2):
    U.unit(x, y)
ans = 0
rest = []
dic = defaultdict(list)
for i in range(N):
    dic[U.find(i)].append(A[i])
for k in list(dic.keys()):
    dic[k].sort()
    ans += dic[k][0]
    rest.extend(dic[k][1:])
if N - 1 == M:
    print((0))
    exit()
if N < 2 * (N - M - 1):
    print("Impossible")
    exit()
rest.sort()
remain = 2 * (N - M - 1) - len(list(dic.keys()))
ans += sum(rest[:remain])
print(ans)

-import sys +class UnionFind: +    def __init__(self, n): +        self.par = [i for i in range(n)] +        self.rank = [0] * n -input = sys.stdin.buffer.readline -from collections import defaultdict -import heapq +    def find(self, x): +        if self.par[x] == x: +            return x +        else: +            self.par[x] = self.find(self.par[x]) +            return self.par[x] + +    def unit(self, x, y): +        x = self.find(x) +        y = self.find(y) +        if x == y: +            return +        elif self.rank[x] < self.rank[y]: +            self.par[x] = y +        elif self.rank[y] < self.rank[x]: +            self.par[y] = x +        else: +            self.par[y] = x +            self.rank[x] += 1 + +    def same(self, x, y): +        return self.find(x) == self.find(y) -def main(): -    N, M = list(map(int, input().split())) -    a = list(map(int, input().split())) -    d = defaultdict(list) -    I = [i for i in range(N)] -    rank = [1 for _ in range(N)] +from collections import defaultdict -    def root(a): -        if I[a] == a: -            return a -        else: -            I[a] = root(I[a]) -            return I[a] - -    def unite(a, b): -        pa, pb = root(a), root(b) -        ra, rb = rank[a], rank[b] -        if ra > rb: -            I[pb] = pa -        else: -            I[pa] = pb -            if ra == rb: -                rank[pb] += 1 - -    for _ in range(M): -        x, y = list(map(int, input().split())) -        unite(x, y) -        parent = root(x) -    for i, num in enumerate(I): -        parent = root(num) -        heapq.heappush(d[parent], a[i]) -    if M == N - 1: -        print((0)) -        exit() -    elif N < 2 * (N - M - 1): -        print("Impossible") -        exit() -    l = len(list(d.keys())) -    ans = 0 -    rest = [] -    for use in list(d.values()): -        ans += heapq.heappop(use) -        rest.extend(use) -    remain = 2 * (N - M - 1) - l -    rest.sort() -    ans += sum(rest[:remain]) -    print(ans) - - -if __name__ == "__main__": -    main() +N, M, *L = list(map(int, open(0).read().split())) +A = L[:N] +U = UnionFind(N) +for x, y in zip(*[iter(L[N:])] * 2): +    U.unit(x, y) +ans = 0 +rest = [] +dic = defaultdict(list) +for i in range(N): +    dic[U.find(i)].append(A[i]) +for k in list(dic.keys()): +    dic[k].sort() +    ans += dic[k][0] +    rest.extend(dic[k][1:]) +if N - 1 == M: +    print((0)) +    exit() +if N < 2 * (N - M - 1): +    print("Impossible") +    exit() +rest.sort() +remain = 2 * (N - M - 1) - len(list(dic.keys())) +ans += sum(rest[:remain]) +print(ans)