// Slower C++ solution:
#include <bits/stdc++.h>



typedef long long LL;



const int MAXN = 1e5 + 5;



int n, m, w[MAXN];



std::multiset<int> st[MAXN];

std::set<std::pair<int, int> > spec;



int fa[MAXN], part;



int Find(int x) {

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

}



void merge(int u, int v) {

    if (Find(u) == Find(v)) return;

    if (st[fa[u]].size() > st[fa[v]].size()) std::swap(u, v);

    --part;

    for (int i: st[fa[u]]) {

        st[fa[v]].insert(i);

    }

    st[fa[u]].clear();

    if (!st[fa[v]].empty()) spec.insert(std::make_pair(st[fa[v]].size(), fa[v]));

    fa[fa[u]] = fa[v];

}



int main() {

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

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

        fa[i] = i;

        scanf("%d", w + i);

        st[i].insert(w[i]);

        spec.insert(std::make_pair(1, i));

    }

    

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

        static int u, v;

        

        scanf("%d%d", &u, &v);

        spec.erase(spec.find(std::make_pair(st[Find(u)].size(), Find(u))));

        spec.erase(spec.find(std::make_pair(st[Find(v)].size(), Find(v))));

        merge(u, v);

    }

    

    LL ans = 0;

    

    while (part > 1) {

        if (spec.size() < 2) {

            puts("Impossible");

            return 0;

        }

        auto x = *--spec.end();

        spec.erase(--spec.end());

        

        auto y = *--spec.end();

        spec.erase(--spec.end());

        

        int u = x.second, v = y.second;

        ans += *st[Find(u)].begin() + *st[Find(v)].begin();

        

        st[Find(u)].erase(st[Find(u)].begin());

        st[Find(v)].erase(st[Find(v)].begin());

        

        merge(u, v);

    }

    

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

    

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.344249818613082x):
#include<iostream>

#include<algorithm>

#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<cstring>

#include<queue>

#include<vector>

#include<map>

using namespace std;

#define llg long long

#define maxn 200010

#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);



inline llg getint()

{

    llg w=0,q=0; char c=getchar();

    while((c<'0' || c>'9') && c!='-') c=getchar();

    if (c=='-')  q=1, c=getchar(); while (c>='0' && c<='9') w=w*10+c-'0', c=getchar();

    return q ? -w : w;

}



struct node{llg val,fa;} a[maxn];



bool cmp(const node &a,const node&b){return a.val<b.val;}



llg n,m,fa[maxn],ans,c[maxn],needb,xian[maxn],chuxian[maxn],bj[maxn];



llg find(llg x) {if (fa[x]!=x) fa[x]=find(fa[x]); return fa[x];}



int main()

{

	cin>>n>>m;

	for (llg i=1;i<=n;i++) c[i]=getint(),fa[i]=i;

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

	{

		llg x=getint(),y=getint();

		x++,y++;

		if (find(x)!=find(y)) fa[find(x)]=find(y);

	}

	for (llg i=1;i<=n;i++) a[i].val=c[i],a[i].fa=find(i);

	sort(a+1,a+n+1,cmp);

	needb=n-1-m;

	llg cs=0;

	for (llg i=1;i<=n && cs<needb*2;i++)

		if (!chuxian[a[i].fa])

		{

			cs++;

			bj[i]=1;

			chuxian[a[i].fa]=1;

			ans+=a[i].val;

		}

	for (llg i=1;i<=n && cs<needb*2;i++)

	{

		if (xian[a[i].fa]<needb && !bj[i])

		{

			xian[a[i].fa]++;

			ans+=a[i].val;

			cs++;

		}

	}

	if (cs<needb*2) puts("Impossible"); else 

	cout<<ans;

	return 0;

}