using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var UF = new UnionFind(N);
		for(int i=0;i<M;i++){
			UF.Unite(X[i], Y[i]);
		}
		
		if(UF.MemCnt(0) == N){
			Console.WriteLine(0);
			return;
		}
		
		SkewHeap<Pair>[] L = new SkewHeap<Pair>[N];
		for(int i=0;i<N;i++) L[i] = new SkewHeap<Pair>();
		for(int i=0;i<N;i++){
			L[UF.Parent(i)].Push(new Pair(i,A[i]));
		}
		
		long tot = 0;
		var SH = new SkewHeap<Pair>();
		
		int rest = (UF.Compo - 1) * 2;
		
		List<Pair> LL = new List<Pair>();
		for(int i=0;i<N;i++){
			if(UF.IsRoot(i)){
				var p = L[i].Top; L[i].Pop();
				tot += p.Cost;
				rest--;
				while(L[i].Count > 0){
					LL.Add(L[i].Top); L[i].Pop();
				}
			}
		}
//Console.WriteLine("ok");
		LL.Sort((p,q) => p.Cost.CompareTo(q.Cost));
		if(LL.Count < rest){
			Console.WriteLine("Impossible");
			return;
		}
		
		for(int i=0;i<rest;i++){
			tot += LL[i].Cost;
		}
		Console.WriteLine(tot);
		
	}
	int N,M;
	long[] A;
	int[] X,Y;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = rla();
		X = new int[M];
		Y = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class UnionFind{
	
	int[] parent;
	int[] mem;
	int compo;
	int N;
	
	public UnionFind(UnionFind v){
		// copy constructor
		N = v.N;
		parent = new int[N];
		mem = new int[N];
		for(int i=0;i<N;i++){
			parent[i] = v.parent[i];
			mem[i] = v.mem[i];
		}
		compo = v.compo;
	}
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N = n_;
		parent = new int[N];
		mem=new int[N];
		for(int i=0;i<N;i++){
			parent[i] = i;
			mem[i] = 1;
		}
		compo = N;
	}
	
	public int Parent(int a){
		if(parent[a] == a)return a;
		return parent[a] = Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a) == Parent(b);
	}
	
	public void Unite(int a,int b){
		a = Parent(a); b = Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a == b)return;
		parent[a] = b;
		mem[b] += mem[a];
		compo -= 1;
	}
	
	public bool IsRoot(int x){
		return x == parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i == 0 ? "{0}" : " {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}


class Pair : IComparable<Pair> {
	public int Pos;
	public long Cost;
	public Pair(int p, long c) {
		Pos = p; Cost = c;
	}
	public int CompareTo(Pair t) {
		//return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0;
		return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0;
	}
	public override String ToString(){
		return String.Format("[{0} {1}]",Pos,Cost);
	}
}


class SkewHeap<T> where T:IComparable<T>{
	public int Count{
		get{return cnt;}
		private set{cnt=value;}
	}
	
	public SkewHeap(){
		root=null;
		this.Count=0;
	}
	
	public void Push(T v){
		NodeSH<T> p=new NodeSH<T>(v);
		root=NodeSH<T>.Meld(root,p);
		this.Count++;
	}
	
	public void Merge(SkewHeap<T> t){
		var cnt0 = this.Count + t.Count;
		root = NodeSH<T>.Meld(root, t.root);
		Count = cnt0;
	}
	
	
	public void Pop(){
		if(root==null)return;
		root=NodeSH<T>.Meld(root.L,root.R);
		this.Count--;
	}
	
	public T Top{
		get{return root.Val;}
	}
	
	public void Dump(){
		if(Count == 0){
			Console.WriteLine("empty");
			return;
		}
		var Q = new Queue<NodeSH<T>>();
		Q.Enqueue(root);
		List<NodeSH<T>> L = new List<NodeSH<T>>();
		while(Q.Count > 0){
			var nd = Q.Dequeue();
			L.Add(nd);
			if(nd.L != null) Q.Enqueue(nd.L);
			if(nd.R != null) Q.Enqueue(nd.R);
		}
		Console.WriteLine(String.Join(" ",L.Select(nd => nd.Val)));
	}
	
	
	int cnt;
	NodeSH<T> root;
	
	class NodeSH<S> where S : IComparable<S> {
		public NodeSH<S> L, R;
		public S Val;

		public NodeSH(S v){
			Val = v;
			L = null; R = null;
		}
		public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b){
			if(a == null)return b;
			if (b == null) return a;
			if (a.Val.CompareTo(b.Val) > 0) swap(ref a, ref b);
			a.R = Meld(a.R, b);
			swap(ref a.L, ref a.R);
			return a;
		}

		static void swap<U>(ref U x, ref U y) {
			U t = x; x = y; y = t;
		}
	}
}



Measured memory_bytes: 38672