#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

struct CountUnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;
    vector<int> cnt;

    CountUnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        cnt.assign(sz, 1);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

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

    bool same(int x, int y){
        return find(x) == find(y);
    }

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

    int get_cnt(int x){
        return cnt[find(x)];
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    for(int i = 0; i < N; ++i)  cin >> a[i];
    CountUnionFind uf(N);
    for(int i = 0; i < M; ++i){
        int x, y;
        cin >> x >> y;
        uf.unite(x, y);
    }

    vector<vector<int>> cost(N);
    for(int i = 0; i < N; ++i)  cost[uf.find(i)].emplace_back(a[i]);
    
    int multi_cnt = 0, one_cnt = 0;
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        if((int)cost[uf.find(i)].size() == 1){
            ++one_cnt;
            ans += a[i];
        }
    }
    for(int i = 0; i < N; ++i){
        if((int)cost[i].size() <= 1)    continue;
        ++multi_cnt;
        sort(cost[i].begin(), cost[i].end());
    }
    if(!multi_cnt){
        if(one_cnt == 1)    cout << 0 << '\n';
        else if(one_cnt == 2)   cout << ans << '\n';    
        else    cout << "Impossible\n";
        return 0;
    }
    if(multi_cnt == 1){
        for(int i = 0; i < N; ++i){
            if(cost[i].size() <= 1) continue;
            if(cost[i].size() < one_cnt)    cout << "Impossible\n";
            else{
                for(int j = 0; j < one_cnt; ++j)    ans += cost[i][j];
                cout << ans << '\n';
            }
            return 0;
        }
    }
    priority_queue<int, vector<int>, greater<int>> que;
    for(int i = 0; i < N; ++i){
        if(cost[i].size() <= 1) continue;
        ans += cost[i][0];
        for(int j = 1; j < (int)cost[i].size(); ++j)    que.emplace(cost[i][j]);
    }
    int rest = multi_cnt - 2 + one_cnt;
    if((int)que.size() < rest){
        cout << "Impossible\n";
        return 0;
    }
    while(rest-- > 0){
        ans += que.top();
        que.pop();
    }
    cout << ans << '\n';
}

Measured memory_bytes: 10332