#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long Int;

priority_queue<Int, vector<Int>, greater<Int> > pq[108000], rest;
Int a[108000];
Int u[108000];
Int x, y;
Int n, m;
bool done[108000];
Int res;
void init(){
	for(int i = 0;i < 108000;i++)u[i] = i;
}

int r(int x){
	if(u[x] == x)return x;
	return u[x] = r(u[x]);
}

void unite(int x, int y){
	x = r(x);
	y = r(y);
	u[x] = y;
}

int main(){
	init();
	cin >> n >> m;
	int need = (n-1-m) * 2;
	if(need > n){
		cout << "Impossible" << endl;
		return 0;
	}
	if(need == 0){
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < m;i++){
		cin >> x >> y;
		unite(x,y);
	}

	for(int i = 0;i < n;i++){
		pq[r(i)].push(a[i]);
	}

	for(int i = 0;i < n;i++){
		if(done[r(i)])continue;
		done[r(i)] = true;
		res += pq[r(i)].top();pq[r(i)].pop();
		while(!pq[r(i)].empty()){
			rest.push(pq[r(i)].top());
			pq[r(i)].pop();
		}
		need--;
	}
	while(need--){
		res += rest.top();rest.pop();
	}
	cout << res << endl;
	return 0;
}