#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;
struct node{
    int val,id;
    const operator < (const node &x) const{
        return val>x.val;
    }
};
priority_queue<int>q;
vector<int>vec[maxn];
int a[maxn],fa[maxn];
int Find(int x){return fa[x]==x?fa[x]:fa[x]=Find(fa[x]);}
void Union(int x,int y){
    int xx=Find(x),yy=Find(y);
    if(xx!=yy) fa[xx]=yy;
}
void read(int &ret){
    ret=0;
    char ch=getchar();
    while(ch>'9'||ch<'0') ch=getchar();
    while(ch>='0'&&ch<='9'){
        ret=ret*10+ch-'0';
        ch=getchar();
    }
}
int main(){
    int n,m;
    read(n),read(m);
    for(int i=0;i<=n;i++) fa[i]=i;
    for(int i=0;i<n;i++){read(a[i]);}
    int u,v;
    for(int i=1;i<=m;i++){
        read(u),read(v);
        Union(u,v);
    }
    if(n==m+1){puts("0");return 0;}
    for(int i=0;i<n;i++){vec[Find(i)].push_back(a[i]);}
    long long ans=0;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(vec[i].size()){
            sort(vec[i].begin(),vec[i].end());
            ans+=vec[i][0];
            cnt++;
            for(int j=1;j<vec[i].size();j++) q.push(vec[i][j]);
        }
    }
    if((n-m-1)*2>n){puts("Impossible");return 0;}
    while(!q.empty()){
        if(cnt>=(n-m-1)*2) break;
        ans+=q.top();q.pop();
        cnt+=1;
    }
    printf("%lld\n",ans);
    return 0;
}
