//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> pii;

const int MAXSU = 1000 * 1000 + 17;

struct DSU {
	int par[MAXSU];
	DSU () {
		memset(par, -1, sizeof(par));
	}
	int find_root(int x) {
		return (par[x] == -1? x: par[x] = find_root(par[x]));
	}
	bool set_union(int x, int y) {
		int p1 = find_root(x), p2 = find_root(y);
		return (p1 == p2? false: (par[find_root(x)] = find_root(y)) | 1);
	}
};

const int MAXN = 100 * 1000 + 17;

int n, m, a[MAXN], cnt;
ll ans;
multiset<int> cmp[MAXN];
vector<int> t;
DSU gr;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++) {
		int v, u;
		cin >> v >> u;
		v++;
		u++;
		gr.set_union(v, u);
	}
	if (m == n - 1)
		return cout << 0 << endl, 0;

	for (int i = 1; i <= n; i++)
		cmp[gr.find_root(i)].insert(a[i]);
	for (int i = 1; i <= n; i++) {
		if (cmp[i].size())
			cnt++;
		else
			continue;
		ans += (*cmp[i].begin());
		cmp[i].erase(cmp[i].begin());
		for (auto j : cmp[i])
			t.pb(j);
	}
	if ((int)t.size() < cnt - 2)
		return cout << "Impossible" << endl, 0;

	sort(t.begin(), t.end());
	for (int i = 0; i < cnt - 2; i++)
		ans += t[i];
	cout << ans << endl;
	return 0;

}