#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define oo 2000000000
const double PI = acos(-1);
const int N = 100010 , K = 201;
int n , m , arr[N] , num = 0;
vector< int > g[N];
vector< int > tmp , v;
bool vis[N];
long long ans = 0;

void DFS(int node){
	vis[node] = true;
	tmp.push_back(arr[node]);
	for(int i=0;i<g[node].size();i++){
		if(vis[g[node][i]]) continue;
		DFS(g[node][i]);
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&arr[i]);
	for(int i=0;i<m;i++){
		int u, v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=0;i<n;i++){
		if(vis[i]) continue;
		tmp.clear();
		DFS(i);
		num++;
		sort(tmp.begin(),tmp.end());
		for(int i=1;i<tmp.size();i++) v.push_back(tmp[i]);
		ans += tmp[0];
	}
 	sort(v.begin(),v.end());
 	if(num - 2 > (int)v.size()){
 		puts("Impossible");
 	}
 	else{
 		for(int i=0;i<num-2;i++) 
 			ans += v[i];
 		if(num == 1)
 			ans = 0;
 		cout << ans << endl;
 	}
 	return 0;
}