// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



#define SZ(x) ((int)x.size())



const int N = 100005;



int n, m;

int a[N];

int fa[N];



vector<int> val[N];



int getfa(int x) {

	return fa[x] == x ? x : fa[x] = getfa(fa[x]);

}



void merge(int x, int y) {

	x = getfa(x);

	y = getfa(y);

	if(SZ(val[x]) < SZ(val[y])) {

		swap(x, y);

	}

	for(auto v: val[y]) {

		val[x].push_back(v);

	}

	val[y].clear();

	fa[y] = x;

}



void input()

{

	scanf("%d%d", &n, &m);

	for(int i = 1; i <= n; i++) {

		scanf("%d", &a[i]);



		val[i].push_back(a[i]);

		fa[i] = i;

	}

	for(int i = 1; i <= m; i++) {

		int x, y;

		scanf("%d%d", &x, &y);

		x++, y++;

		merge(x, y);

	}

}



void solve()

{

	long long ans = 0;



	int cnt = (n - 1 - m) * 2;



	if(cnt == 0) {

		puts("0");

		return;

	}



	vector<int> vec;

	for(int i = 1; i <= n; i++) {

		if(fa[i] == i) {

			sort(val[i].begin(), val[i].end());

			ans += val[i][0];

			cnt--;

			for(int j = 1; j < SZ(val[i]); j++) {

				vec.push_back(val[i][j]);

			}

		}

	}



	if(SZ(vec) < cnt) {

		puts("Impossible");

		return;

	}



	sort(vec.begin(), vec.end());

	for(int i = 0; i < cnt; i++) {

		ans += vec[i];

	}

	cout << ans << endl;

}



int main()

{

	input();

	solve();



	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.538776711435616x):
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define sd(x) scanf("%d", &(x))

#define pii pair<int, int>

#define F first

#define S second

#define all(c) ((c).begin()), ((c).end())

#define sz(x) ((int)(x).size())

#define ld long double



template<class T,class U>

ostream& operator<<(ostream& os,const pair<T,U>& p){

	os<<"("<<p.first<<", "<<p.second<<")";

	return os;

}



template<class T>

ostream& operator <<(ostream& os,const vector<T>& v){

	os<<"{";

	for(int i = 0;i < (int)v.size(); i++){

		if(i)os<<", ";

		os<<v[i];

	}

	os<<"}";

	return os;

}



#ifdef LOCAL

#define cerr cout

#else

#endif



#define TRACE



#ifdef TRACE

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1){

	cerr << name << " : " << arg1 << std::endl;

}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){

	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);

}

#else

#define trace(...)

#endif



struct dsu{

    int n;

    vector<int> par;

    vector<vector<int>> comp;

    int num;

    dsu(int n) : n(n), par(n), comp(n), num(n){

        iota(par.begin(), par.end(), 0);

    }

    int root(int x){

        return x == par[x] ? x : (par[x] = root(par[x]));

    }

    bool merge(int x, int y){

        x = root(x); y = root(y);

        if(x == y) return 0;

        par[x] = y;

        num--;

        return 1;

    }

    void get(){

        for(int i = 0; i < n; i++) comp[root(i)].push_back(i);

    }

};





int a[100005];

int main(){

    int n, m; sd(n); sd(m);

    for(int i = 0; i < n; i++) sd(a[i]);

    dsu D(n);

    for(int i = 0; i < m; i++){

        int u, v;

        sd(u); sd(v);

        D.merge(u, v);

    }

    if(D.num == 1){

        printf("0\n");

        return 0;

    }

    D.get();

    vector<int> rem;

    ll ans = 0;

    int num = 0;

    for(int i = 0; i < n; i++) if(!D.comp[i].empty()){

        vector<int> V = D.comp[i];

        sort(all(V), [&](int i, int j){

            return a[i] < a[j];

        });

        ans += a[V[0]];

        for(int j = 1; j < sz(V); j++) rem.push_back(a[V[j]]);

    }

    if(sz(rem) < D.num - 2){

        printf("Impossible\n");

        return 0;

    }

    sort(all(rem));

    for(int i = 0; i < D.num - 2; i++) ans += rem[i];

    printf("%lld\n", ans);

}