#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second 
using namespace std;

int n, m, aim, las, fa[101000], cnt[101000], used[101000], fl[101000];
pii a[101000];
long long ans;

int GF(int x){
  return x==fa[x]? x: fa[x]=GF(fa[x]);
}

int main(){
  cin>>n>>m; aim=n-1-m;
  for (int i=1;i<=n;++i){
    scanf("%d",&a[i].fi); a[i].se=fa[i]=i;
  }
  int x,y;
  for (;m--;){
    scanf("%d%d",&x,&y); ++x; ++y;
    if (GF(x)!=GF(y)) fa[GF(x)]=GF(y);
  }
  sort(a+1,a+n+1);
  las=aim*=2;
  for (int i=1;i<=n&&las;++i){
    if (!used[GF(a[i].se)]){
      used[GF(a[i].se)]=1;
      ans+=a[i].fi; ++cnt[GF(a[i].se)];
      --las; fl[i]=1;
    }
  }
  for (int i=1;i<=n&&las;++i) if (!fl[i]){
    if ((cnt[GF(a[i].se)]+1)*2<=aim){
      //printf("%d\n",a[i].se);
      ans+=a[i].fi; ++cnt[GF(a[i].se)];
      --las;
    }
  }
  if (las) return 0*puts("Impossible");
  cout<<ans;
} 