#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#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 Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

template<class T>
T binary(T key,const vector<T> &g){
    T ng = -1;
    T ok = (T)g.size();
    while(abs(ok-ng)>1){
        T mid = (ok+ng)/2;
        if(gcd(g[mid],key)==1){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return ok;
}

struct UnionFind{
private:
    vector<int> par;

public:
    UnionFind(int n=0): par(n,-1){ }

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

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

    bool unite(int x, int y){
        x = find(x); y = find(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y] = x;
        return true;
    }

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

    int count_group(){
        int c = 0;
        rep(i,par.size()){
            if(par[i]<0) c++; 
        }
        return c;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<ll> a(n);
    graph g(n);
    rep(i,n) cin >> a[i];
    rep(i,m){
        int x,y; cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vector<priority_queue<ll,vector<ll>,greater<ll>>> d;
    vector<bool> seen(n,false);
    queue<int> que;
    rep(i,n){
        if(seen[i]) continue;
        que.push(i);
        seen[i] = true;
        priority_queue<ll,vector<ll>,greater<ll>> p;
        while(!que.empty()){
            int t = que.front();
            p.push(a[t]);
            que.pop();
            for(auto nt: g[t]){
                if(seen[nt]) continue;
                else{
                    que.push(nt);
                    seen[nt] = true;
                }
            }
        }
        d.emplace_back(p);
    }
    ll ans = 0;
    int flag = 0;
    int si = 0;
    rep(i,d.size()){
        if(si<d[i].size()){
            si = d[i].size();
            flag = i;
        }
    }
    for(int i = 0; i<d.size(); i++){
        if(i==flag) continue;
        if(d[flag].empty() || d[i].empty()){
            cout << "Impossible" << endl;
            return 0;
        }
        ans += (d[i].top()+d[flag].top());
        d[i].pop();
        d[flag].pop();
        while(!d[i].empty()){
            d[flag].push(d[i].top());
            d[i].pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12016