#include<bits/stdc++.h>
using namespace std;

const int N = 100005;

int n, m, a[N], p[N], c;
vector<int> v;

int Find (int X) {
	if(p[X] == X) return X;
	return p[X] = Find(p[X]);
}

void Union (int A, int B) {
	A = Find(A);
	B = Find(B);
	if(a[A] > a[B]) swap(A, B);
	p[B] = A;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		p[i] = i;
	}
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		Union(A, B);
	}
	long long ans = 0;
	for(int i=0;i<n;i++) {
		if(Find(i) != i) v.push_back(a[i]);
		else {
			ans += a[i];
			c++;
		}
	}
	if(c == 1) {
		puts("0");
		return 0;
	}
	sort(v.begin(), v.end());
	if((int)v.size() < c-2) {
		puts("Impossible");
		return 0;
	}
	for(int i=0;i<c-2;i++) {
		ans += v[i];
	}
	printf("%lld\n",ans);
}
