// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;



const int maxn = 1e5 + 5;



int n, m, k;

int w[maxn], f[maxn];

ll ans;

priority_queue <int, vector<int>, greater<int>> q[maxn];

multiset <int> s;



int find(int x)

{

	return f[x] == x ? x : f[x] = find(f[x]);

}



void merge(int x, int y)

{

	int fx = find(x);

	int fy = find(y);

	if(fx != fy)

		f[fx] = fy;

}



int main()

{

	int u, v;

	scanf("%d%d", &n, &m);

	k = n - m;

	if(2 * k - 2 > n)

	{

		puts("Impossible");

		return 0;

	}

	if(k == 1)

	{

		puts("0");

		return 0;

	}

	for(int i = 1; i <= n; i++)

	{

		scanf("%d", &w[i]);

		f[i] = i;

	}

	for(int i = 1; i <= m; i++)

	{

		scanf("%d%d", &u, &v);

		u++, v++;

		merge(u, v);

	}

	for(int i = 1; i <= n; i++)

	{

		find(i);

		q[f[i]].push(w[i]);

	}

	for(int i = 1; i <= n; i++)

		if(!q[i].empty())

		{

			ans += q[i].top();

			q[i].pop();

	//		printf("val = %lld\n", val);

		}

	for(int i = 1; i <= n; i++)

		while(!q[i].empty())

		{

			s.insert(q[i].top());

			q[i].pop();

		}	

//	for(auto it = s.begin(); it != s.end(); it++)

//		printf("%d\n", *it);

	auto it = s.begin();

	for(int i = 1; i <= k - 2; i++, it++)

	{

		ans += *it;

	//	printf("%lld\n", ans);

	}

	printf("%lld\n", ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.395728326722889x):
#include <bits/stdc++.h>

using namespace std;



const int MAXN = 101010;



int a[MAXN];



class Node {

public:

	int v;

	Node *l, *r;

	int key;

	

	Node(int x) {

		v = a[x];

		l = r = 0;

		key = 1;

	}

};



//set<pair<int,int> > s;



class Road {

public:

	int t, next;

}e[MAXN * 2];

int p[MAXN];

int z = -1;



int vis[MAXN];



void add(int u, int v) {

	++z;

	e[z].t = v;

	e[z].next = p[u];

	p[u] = z;

}



Node *root[MAXN];



int getkey(Node *now) {

	return now ? now->key : 0;

}



void update(Node *now) {

	now->key = getkey(now->r) + 1;

}



Node* merge(Node *&l, Node *&r) {

	if(!l)

		return r;

	if(!r)

		return l;

//	cout<<l->v<<" "<<r->v<<endl;

	if(l->v < r->v) {

		l->r = merge(l->r, r);

		if(getkey(l->l) < getkey(l->r))

			swap(l->l, l->r);

		update(l);

		return l;

	}

	else {

		r->r = merge(l, r->r);

		if(getkey(r->l) < getkey(r->r))

			swap(r->l, r->r);

		update(r);

		return r;

	}

}



void dfs(int u, int fa, int tag) {

	vis[u] = tag;

	if(u != tag) {

		root[tag] = merge(root[tag], root[u]);

		root[u] = 0;

	}

	for(int tmp = p[u]; tmp != -1; tmp = e[tmp].next) {

		if(e[tmp].t != fa) {

			dfs(e[tmp].t, u, tag);

		}

	}

} 



void del(Node *&now) {

	//print(now);

	now = merge(now->l, now->r);

}





int n, m;



int main() {

	scanf("%d%d", &n, &m);

	for(int i = 0; i < n; ++i) {

		scanf("%d", &a[i]);

		root[i] = new Node(i);

	}

	int u, v;

	memset(p, -1, sizeof(p));

	

	for(int i = 1; i <= m; ++i) {

		scanf("%d%d", &u, &v);

		add(u, v);

		add(v, u);

	}

	memset(vis, -1, sizeof(vis));

	

	int cnt = 0;

	long long ss = 0;

	Node *tmp = 0;

	for(int i = 0; i < n; ++i) {

		if(vis[i] == -1) {

			++cnt;

			dfs(i, -1, i);

			ss += root[i]->v;

			del(root[i]);

			tmp = merge(tmp, root[i]);

		}

	}

	if((n - 1 - m) * 2 > n) {

		puts("Impossible");

		return 0;

	}

	if(m == n - 1) {

		puts("0");

		return 0;

	}

	

	int need = (n - 1 - m) * 2 - cnt;

	for(int i = 1; i <= need; ++i) {

		ss += tmp->v;

		del(tmp);

	}

	

	//if(cnt >= n - 1) {

		printf("%lld\n", ss);

	//}

	/*else {

		puts("Impossible");

	}*/



	return 0;

}