#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
class UnionFind {
    vector<int> p;//p[i]はiの属する組織
public:
    UnionFind(int n) {
        p = vector<int>(n);
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
        return;
    }

    void printState() {
        if (DEBUG) {
            cout << "---" << endl;
            for (int i = 0; i < p.size(); i++) {
                printf("%dの親は%d\n", i, p[i]);
            }
            cout << "---" << endl;
        }
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        p[find(x)] = p[find(y)];
    }

/* xとyが属する集合が同じかを判定する */
    bool same(int x, int y) {
        return find(x) == find(y);
    }

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);


    int N, M;
    cin >> N >> M;
    vector<int> cost(N);
    rep(i, 0, N) cin >> cost[i];
//    rep(i, 0, N) scanf("%d",&cost[i]);
    UnionFind uf1(N);
    rep(i, 0, M) {
        int x, y;
        cin >> x >> y;
//        scanf("%d %d",&x,&y);
        uf1.unite(x, y);
    }
//    set<int> mori_k;
    map<int, int> mori_k;
//    vector<vector<int>> mori;
    vector<priority_queue<int> > mori;

    rep(i, 0, N) {
        if (mori_k.find(uf1.find(i)) == mori_k.end()) {
//            mori_k.insert(uf1.find(i));
            mori_k[uf1.find(i)] = mori.size();
//            mori.push_back(vector<int>(0,cost[i]));
            mori.push_back(priority_queue<int>());
            mori.back().push(-cost[i]);
        } else {
            mori[mori_k[uf1.find(i)]].push(-cost[i]);
        }
    }
//    priority_queue<pair<int, int> > at1, sono;
//    rep(i, 0, mori.size()) {
//        if (mori[i].size() == 1) {
//            at1.emplace(mori[i].top(), i);
//        } else {
//            sono.emplace(mori[i].top(), i);
//        }
//    }
    ll ans = 0LL;
    //check
    int kihen = (mori.size() - 1) * 2;
    int sum_hen = 0;
    rep(i, 0, mori.size()) {
        sum_hen += mori[i].size();
    }
    if (sum_hen < kihen) {
        cout << "Impossible" << endl;
        return 0;
    }else if(N - 1 == M){
        cout << 0 << endl;
        return 0;
    }

    priority_queue<int> pq;
    rep(i,0,mori.size()){
        ans += -1LL * mori[i].top();
        mori[i].pop();
        while(!mori[i].empty()){
            pq.push(mori[i].top());
            mori[i].pop();
        }
    }
    rep(i,0,mori.size() - 2){
        ans += -1LL * pq.top();
        pq.pop();
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 12780