// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

const int maxn=100010;

multiset<int> S[maxn];

set<pair<int,int> > S2;

struct Edge

{

	int v,next;

}	e[maxn<<1];

int g[maxn],tot;

void addedge(int x,int y)

{

	tot++;

	e[tot].v=y;

	e[tot].next=g[x];

	g[x]=tot;

}

int n,m;

bool vis[maxn];

int a[maxn];



void dfs(int t,int ha)

{

	S[ha].insert(a[t]);

	vis[t]=true;

	for (int i=g[t];i;i=e[i].next)

	if (!vis[e[i].v])

		dfs(e[i].v,ha);

}

int Union(pair<int,int> x,pair<int,int> y)

{

	multiset<int>::iterator it=S[x.second].lower_bound(x.first);

	S[x.second].erase(it);

	it=S[y.second].lower_bound(y.first);

	S[y.second].erase(it);

	int l=x.second,r=y.second;

	if (S[l].size()>S[r].size())	swap(l,r);

	for (auto i:S[l])

		S[r].insert(i);

	S[l].clear();

	return r;

}

int main()

{

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

	for (int i=1;i<=n;i++)	scanf("%d",&a[i]);

	for (int i=1;i<=m;i++)

	{

		int x,y;

		scanf("%d%d",&x,&y);

		x++;y++;

		addedge(x,y);

		addedge(y,x);

	}

	for (int i=1;i<=n;i++)

	if (!vis[i])

		dfs(i,i);

	for (int i=1;i<=n;i++)

		if (!S[i].empty())

			S2.insert(make_pair(S[i].size(),i));

	ll ans=0;

	for (int i=1;i<=n-1-m;i++)

	{

		if (S2.empty())

		{

			printf("Impossible\n");

			return 0;

		}

		pair<int,int> tmp1=*--S2.end();

		S2.erase(--S2.end());

		if (S2.empty())

		{

			printf("Impossible\n");

			return 0;

		}

		pair<int,int> tmp2=*--S2.end();

		S2.erase(--S2.end());

		tmp1.first=*S[tmp1.second].begin();

		tmp2.first=*S[tmp2.second].begin();

		ans+=tmp1.first+tmp2.first;

		int q=Union(tmp1,tmp2);

		if (!S[q].empty())	S2.insert(make_pair(S[q].size(),q));

	}

	printf("%lld\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include<cstdio>

#include<set>

#include<queue>

#include<vector>

#include<map>

#include<cmath>

#include<cstdlib>

#include<algorithm>

#include<string>

#include<cstring>



using namespace std;



int a[100005],fa[100005],vis[100005],mi[100005];

priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int> > >q;



int _find(int x)

{

    return fa[x]==x?x:fa[x]=_find(fa[x]);

}



void _merge(int x,int y)

{

    int fx=_find(x),fy=_find(y);

    if(fx!=fy)

    {

        fa[fx]=fy;

    }

}

int main()

{

	int n,m;

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

	for(int i=0;i<n;i++)

	{

	    scanf("%d",&a[i]);

	    fa[i]=i;

	    mi[i]=1e9+9;

	}

	int x,y;

	for(int i=0;i<m;i++)

    {

        scanf("%d %d",&x,&y);

        _merge(x,y);

    }

	for(int i=0;i<n;i++)

        _find(i);

    pair<int,int>tt;

	for(int i=0;i<n;i++)

	{

	    mi[fa[i]]=min(a[i],mi[fa[i]]);



	    tt.first=a[i];

	    tt.second=fa[i];

	    q.push(tt);

	}

	sort(fa,fa+n);

	int cnt=unique(fa,fa+n)-fa;

	if(cnt==1)

        printf("0\n");

    else

    {

        long long ans=0;

        for(int i=0;i<cnt;i++)

            ans+=mi[fa[i]];

        while(!q.empty())

        {

            if(cnt==2)

                break;

            pair<int,int>tmp;

            tmp=q.top();

            q.pop();

            if(vis[tmp.second]==0)

            {

                vis[tmp.second]=1;

                continue;

            }

            ans+=tmp.first;

            cnt--;

        }

        if(cnt==2)

            printf("%lld\n",ans);

        else

            printf("Impossible\n");

    }

    return 0;

}


// Fastest known solution for this problem: