#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(kbrni,n)cout<<" "<<a[kbrni];cout<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define svecp(v) cout<<#v<<":";each(kbrni,v)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

class UF {
private:
    int sz;
public:
    vector<int> kind;   //所属しているグループ番号
    vector<vector<int> > inc;   //グループのメンバー
    UF(){}
    UF(int node_size){ sz = node_size; kind.resize(sz),inc.resize(sz); rep(i,sz){ kind[i] = i; inc[i].pb(i); } }
    bool same(int a,int b){ return kind[a] == kind[b]; }
    void unite(int a,int b)
    { if(same(a,b)) return; if(inc[kind[a]].size() < inc[kind[b]].size()) swap(a,b);
        int ga = kind[a],gb = kind[b]; rep(i,inc[gb].size()) kind[inc[gb][i]] = ga;
        inc[ga].insert(inc[ga].end(),inc[gb].begin(),inc[gb].end()); inc[gb].clear(); }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vl a(n);
    rep(i,n){
        cin >> a[i];
    }
    UF uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        uf.unite(a,b);
    }
    vvi& inc = uf.inc;
    vector<multiset<ll> > vec;
    ll ans = 0;
    int cnt = 0;
    rep(i,len(inc)){
        if(len(inc[i]) >= 2){
            vec.pb(multiset<ll>());
            rep(j,len(inc[i])){
                vec.back().insert(a[inc[i][j]]);
            }
        }else if(len(inc[i])){
            ans += a[inc[i][0]];
            cnt++;
        }
    }
    int sz = len(vec);
    if(sz == 0){
        if(cnt == 1){
            cout << "0\n";
            return 0;
        }else if(cnt == 2){
            cout << ans << "\n";
            return 0;
        }else{
            cout << "Impossible\n";
            return 0;
        }
    }
    priority_queue<pli,vector<pli>,greater<pli> > que;
    rep(i,sz){
        que.push(pli(*vec[i].begin()+*(++vec[i].begin()),i));
    }
    rep(i,sz-1){
        pli p = que.top();
        que.pop();
        pli q = que.top();
        que.pop();
        ans += *vec[p.se].begin() + *vec[q.se].begin();
        vec[p.se].erase(vec[p.se].begin());
        vec[q.se].erase(vec[q.se].begin());
        if(len(vec[p.se]) < len(vec[q.se])){
            while(!vec[p.se].empty()){
                vec[q.se].insert(*vec[p.se].begin());
                vec[p.se].erase(vec[p.se].begin());
            }
            que.push(pli(*vec[q.se].begin()+*(++vec[q.se].begin()),q.se));
        }else{
            while(!vec[q.se].empty()){
                vec[p.se].insert(*vec[q.se].begin());
                vec[q.se].erase(vec[q.se].begin());
            }
            que.push(pli(*vec[p.se].begin()+*(++vec[p.se].begin()),p.se));
        }
    }
    assert(len(que) == 1);
    int id = que.top().se;
    if(len(vec[id]) >= cnt){
        int lp = 0;
        each(it,vec[id]){
            if(lp == cnt){
                break;
            }
            ans += it;
            lp++;
        }
    }else{
        cout << "Impossible\n";
        return 0;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12460