#include<bits/stdc++.h>
#define maxl 100010

using namespace std;

int n,m,cnt;
bool flag;
long long ans;
int a[maxl],f[maxl],b[maxl];
map <int,int> mp[maxl];
map <int,int> ::iterator it;
struct node
{
	int val,id;
	bool operator < (const node &b) const
	{
		if(val==b.val)
			return id<b.id;
		else
			return val<b.val;
	}
	bool operator == (const node  &b) const
	{
		return val==b.val && id==b.id;
	}
};
set <node> s;

inline int find(int x)
{
	if(f[x]!=x)
		f[x]=find(f[x]);
	return f[x];
}

inline void prework()
{
	for(int i=1;i<=n;i++)
	{
		f[i]=i;
		mp[i].clear();
	}
	s.clear();
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int u,v,x,y;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		u++;v++;
		x=find(u);y=find(v);
		if(x!=y)
			f[y]=x;
	}
	for(int i=1;i<=n;i++)
		x=find(i);
	for(int i=1;i<=n;i++)
		mp[f[i]][a[i]]++;

}

inline void mainwork()
{
	ans=0;flag=true;node d1,d2;
	int x,y,res=2*(n-1-m);
	cnt=0;
	for(int i=1;i<=n && res>0;i++)
	if(mp[i].begin()!=mp[i].end())
	{
		ans+=mp[i].begin()->first;
		mp[i].begin()->second--;
		res--;
		if(mp[i].begin()->second==0)
			mp[i].erase(mp[i].begin());
		for(it=mp[i].begin();it!=mp[i].end();++it)
		{
			for(int j=1;j<=it->second;j++)
				b[++cnt]=it->first;	
		}
	}
	if(cnt<res)
	{
		flag=false;
		return;
	}
	sort(b+1,b+1+cnt);
	for(int i=1;i<=res;i++)
		ans+=b[i];
	
	/*for(int i=1;i<=n-1-m;i++)
	{
		if(s.size()<2)
		{
			flag=false;
			return;
		}
		d1=(*s.begin());s.erase(s.begin());
		d2=(*s.begin());s.erase(s.begin());
		x=d1.id;y=d2.id;
		ans+=d1.val+d2.val;
		mp[x][d1.val]--;mp[y][d2.val]--;
		if(mp[x].size()<mp[y].size())
			swap(x,y);
		f[y]=x;
		for(it=mp[y].begin();it!=mp[y].end();++it)
			mp[x][it->first]+=it->second;
		mp[y].clear();
		while(mp[x].begin()->second==0)
		{	
			mp[x].erase(mp[x].begin());
			if(mp[x].size()==0)
				break;
		}
		if(mp[x].size()>0)
			s.insert(node{mp[x].begin()->first,x});
	}*/
}

inline void print()
{
	if(flag)
		printf("%lld\n",ans);
	else
		puts("Impossible");
}

int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}
 