#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
vector<long long> m1,m2,a,G[100005];
vector<vector<long long> > C;
long long cnt;
bool visited[100005];
void dfs(long long u)
{
	long long i;
	visited[u]=true;
	C[cnt].push_back(a[u]);
	for(i=0;i<G[u].size();i++)
	{
		if(!visited[G[u][i]])
		{
			dfs(G[u][i]);
		}
	}
}
int main()
{
	long long j,N,M,i,u,v,ans;
	cin>>N>>M;
	memset(visited,false,sizeof(visited));
	a.resize(N+1);
	for(i=1;i<=N;i++)
		cin>>a[i];
	while(M--)
	{
		cin>>u>>v;
		u++;
		v++;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	cnt=0;
	for(i=1;i<=N;i++)
	{
		if(!visited[i])
		{
			C.push_back(vector<long long>());
			dfs(i);
			cnt++;
		}
	}
	if(cnt==1)
	{
		cout<<0<<"\n";
		return 0;
	}
	for(i=0;i<cnt;i++)
	{
		sort(C[i].begin(),C[i].end(),greater<long long>());
		m1.push_back(C[i].back());
		C[i].pop_back();
		for(j=0;j<C[i].size();j++)
			m2.push_back(C[i][j]);
	}
	ans=0;
	for(i=0;i<m1.size();i++)
	{
		ans+=m1[i];
	}
	sort(m2.begin(),m2.end());
	if((long long)m2.size()<cnt-2)
	{
		cout<<"Impossible\n";
		return 0;
	}
	for(i=0;i<cnt-2;i++)
	{
		ans+=m2[i];
	}
	cout<<ans<<"\n";
	return 0;
}
