// Slower C++ solution:
#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);

}

// Faster C++ solution for the same problem (measured speedup: 5.217126098949729x):
#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

int p[100100];

ll ans;

int n, m;

pair<ll, int> a[100100];

bool group_used[100100];

bool used[100100];

int root(int x) { return x == p[x] ? x : p[x] = root(p[x]); }

int main()

{

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

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

	{

		ll cost;

		scanf("%lld", &cost);

		a[i] = make_pair(cost, i);

	}

	for (int i = 1; i <= n; i++) p[i] = i;

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

	{

		int u, v;

		scanf("%d%d", &u, &v);

		u++; v++;

		p[root(u)] = root(v);

	}

	int g = 0;

	for (int i = 1; i <= n; i++) if (p[i] == i) g++;

	// need to group g supernodes into a tree. need to have:

	//   sum of degree = 2(g-1) <= number of nodes = n

	if (2 * (g - 1) > n)

	{

		printf("Impossible\n");

		return 0;

	}

	// select smallest cost from each group first

	// then select smallest from rest

	sort(&a[1], &a[n + 1]);

	int dsum = 0;

	for (int i = 1; i <= n && dsum < 2 * (g - 1); i++)

	{

		int x = a[i].second;

		int r = root(x);

		if (group_used[r] || used[x]) continue;

		group_used[r] = used[x] = true;

		ans += a[i].first;

		dsum++;

	}

	for (int i = 1; i <= n && dsum < 2 * (g - 1); i++)

	{

		int x = a[i].second;

		if (used[x]) continue;

		ans += a[i].first;

		dsum++;

	}

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

	return 0;

}