#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
typedef pair<int,int> pii;
int w[10005];
int no[10005];
int fa[10005];
int num[10005];
pii node[10005];
bool vis[10005];
int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}
bool merge(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx==fy) return false;
	fa[fx]=fy;
	return true;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) fa[i]=i;
	for(int i=0;i<n;i++) scanf("%d",&w[i]);
	int treenum=n-m;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		merge(u,v);
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(fa[i]==i) no[i]=cnt++;
	}
	for(int i=0;i<n;i++)
	{
		if(fa[i]!=i) no[i]=no[find(i)];
	}
	int tot=0;
	for(int i=0;i<n;i++){
		node[tot++]=pii(w[i],no[i]);
	}
	memset(num,0,sizeof(num));
	memset(vis,0,sizeof(vis));
	int ans=0;
	sort(node,node+tot);
	int can=0;
	for(int i=0;i<tot;i++){
		if(can==(treenum-1)*2) break;
		if(!num[node[i].second]){
			vis[i]=1;
			can++;
			num[node[i].second]=1;
			ans+=node[i].first;
		}
	}
	for(int i=0;i<tot;i++)
	{
		if(can==(treenum-1)*2) break;
		if(!vis[i]&&num[node[i].second]<treenum-1){
			num[node[i].second]++;
			can++;
			ans+=node[i].first;
		}
	}
	if(can!=(treenum-1)*2) printf("Impossible\n");
	else printf("%d\n",ans);
}