#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
struct UnionFind {
    vector<int> par;
    vector<int> count;
    vector<int> rank;

    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = find(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[find(x)];
    }

    bool issame(int x, int y) {
        return find(x) == find(y);
    }
};
using UF = struct UnionFind;

int main() {
    init();
    ll N, M;
    cin >> N >> M;
    vc<priority_queue<pair<ll,ll>, vc<pair<ll,ll>>, greater<pair<ll,ll>>>> pql(N);
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }

    UF uf(N);
    rep(i,M){
        ll x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    ll usevn = 2 * (N - M - 1);
    if(N<usevn){ //満たさない
        cout << "Impossible" << endl;
        return 0;
    }
    else if(M==N-1){
        cout << 0 << endl;
        return 0;
    }

    vc<pair<ll,ll>> B(N, {INF,INF});
    rep(i,N){
        chmin(B[uf.find(i)], {A[i], i});
    }
    vc<bool> used(N, false);
    rep(i,N){
        if (B[i].first == INF) continue;
        used[B[i].second] = true;
        pql[uf.find(i)].emplace(B[i]);
        usevn--;
    }
    priority_queue<pair<ll, ll>, vc<pair<ll, ll>>, greater<pair<ll, ll>>> allpq;
    rep(i, N) allpq.emplace(A[i], i);
    while(usevn){
        ll v, p;
        tie(v, p) = allpq.top(), allpq.pop();
        if (used[p]) continue;
        pql[uf.find(p)].emplace(v, p);
        usevn--;
    }


    priority_queue<pair<ll, ll>, vc<pair<ll, ll>>, greater<pair<ll, ll>>> mte2; //選択可能な頂点が2以上ある木の最小頂点をpqで持つ
    queue<pair<ll, ll>> only1v; //使える頂点が１つの木の最小頂点を集める
    rep(i,N){
        ll V = pql[i].size();
        if(V==1){
            only1v.emplace(pql[i].top());
        }else if(V>=2){
            mte2.emplace(pql[i].top());
        }
    }

    ll ans = 0;
    while(!mte2.empty()){
        ll pv, pi;
        tie(pv, pi) = mte2.top(), mte2.pop();

        ll cv, ci;
        if(!only1v.empty()){
            tie(cv, ci) = only1v.front(), only1v.pop();
            ans += pv + cv;

            ll parent_pi = uf.find(pi);
            pql[uf.find(ci)].pop();
            pql[parent_pi].pop();

            if(pql[parent_pi].size()==1){
                only1v.emplace(pql[parent_pi].top());
            }else{
                mte2.emplace(pql[parent_pi].top());
            }
            
        }else{
            if (mte2.empty()) break;

            tie(cv, ci) = mte2.top(), mte2.pop();
            ans += pv + cv;

            ll parent_pi = uf.find(pi), parent_ci = uf.find(ci);
            pql[parent_pi].pop(), pql[parent_ci].pop();

            uf.unite(parent_pi, parent_ci);
            ll new_p = uf.find(parent_pi);
            ll other_p = (new_p != parent_pi ? parent_pi : parent_ci);

            while(!pql[other_p].empty()){
                pql[new_p].emplace(pql[other_p].top()), pql[other_p].pop();
            }
            
            if(pql[new_p].size()==1){
                only1v.emplace(pql[new_p].top());
            }else{
                mte2.emplace(pql[new_p].top());
            }
        }
    }

    if(only1v.size()>2){
        cout << "Impossible" << endl;
        return 0;
    }
    else if(only1v.size()==2){
        ans += only1v.front().first, only1v.pop();
        ans += only1v.front().first, only1v.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 12272