#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,m,a[N],f[N];
priority_queue<int,vector<int>,greater<int> >q[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
priority_queue<int,vector<int>,greater<int> >s;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++) f[i]=i;
    while(m--)
    {
        int u,v;scanf("%d%d",&u,&v);
        u++;v++;
        f[getf(u)]=getf(v);
    }
    for(int i=1;i<=n;i++) q[getf(i)].push(a[i]);
    int tot=0,sum;
    for(int i=1;i<=n;i++)
        if(f[i]==i) tot++;
    if(tot==1){printf("0\n");return 0;}
    sum=(tot-1)*2;
    ll ans=0;
    for(int i=1;i<=n;i++)
        if(f[i]==i)
    {
        ans+=q[i].top(),q[i].pop();
        while(!q[i].empty())
            s.push(q[i].top()),q[i].pop();
        sum--;
    }
    while(sum&&!s.empty())
    {
        sum--;ans+=s.top();s.pop();
    }
    if(sum) printf("Impossible\n");
    else printf("%lld\n",ans);
}
