#include <bits/stdc++.h>

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 1e5 + 10;

int A[N];

struct cmp{
	bool operator () (int x, int y){
		return A[x] > A[y];
	}
};

priority_queue<int, vector<int>, cmp> q;
int n, m;

int fa[N];
int find(int x){
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

bool vis[N];

int main(){

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

	if(n == m + 1){
		puts("0");
		return 0;
	}
		
	For(i, 1, n) scanf("%d", &A[i]), fa[i] = i;
	For(i, 1, n) q.push(i);
	For(i, 1, m){
		int u, v;
		scanf("%d%d", &u, &v);
		++u, ++v;
		fa[find(u)] = find(v);
	}

	long long ans = 0;
	int s = n - m - 2, cnt = 0;

	while(!q.empty()){
		int i = q.top(), o = find(i); q.pop();
		if(vis[o] && cnt < s) ++cnt, ans += A[i];
		else if(!vis[o]) vis[o] = true, ans += A[i];
	}
	
	if(cnt == s) printf("%lld\n", ans);
	else puts("Impossible");

	return 0;
}