/*
PROG: apc001d
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long mod)
{
	return ((1 << 30) * rand() + (1 << 15) * rand() + rand()) % mod;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-20;

#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll
#define MAXN 100010

long long normalize(long long x, long long mod = INF)
{
	return (((x % mod) + mod) % mod);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N, M;
ll arr[MAXN];
int dsu[MAXN];
vector<ll> vals[MAXN], overall;
ll ans;
priority_queue<ll, vector<ll>, greater<ll> > pq;

int find_par(int u)
{
	if (u == dsu[u])
	{
		return u;
	}
	dsu[u] = find_par(dsu[u]);
	return dsu[u];
}
void merge(int u, int v)
{
	u = find_par(u);
	v = find_par(v);
	dsu[u] = v;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); 
	srand(time(0));
	//	cout << fixed << setprecision(12);	
	//	cerr << fixed << setprecision(12);
	if (fopen("apc001d.in", "r"))
	{	
		freopen ("apc001d.in", "r", stdin);
		freopen ("apc001d.out", "w", stdout);
	}
	cin >> N >> M;
	if (M + 1 == N)
	{
		cout << "0\n";
		return 0;
	}
	int cnt = (N - 1 - M) * 2;
	if (cnt > N)
	{
		cout << "Impossible\n";
		return 0;
	}
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
		dsu[i] = i;
	}
	for (int i = 0; i < M; i++)
	{
		int u, v;
		cin >> u >> v;
		merge(u, v);
	}
	for (int i = 0; i < N; i++)
	{
		vals[find_par(i)].PB(arr[i]);
	}
	for (int i = 0; i < N; i++)
	{
		if (find_par(i) != i)
		{
			continue;
		}
		sort(vals[i].begin(), vals[i].end());
		reverse(vals[i].begin(), vals[i].end());
		ans += vals[i].back();
		vals[i].pop_back();
		for (ll x : vals[i])
		{
			overall.PB(x);
		}
		cnt--;
	}
	sort(overall.begin(), overall.end());
	for (int i = 0; i < cnt; i++)
	{
		ans += overall[i];
	}
	cout << ans << '\n';
	//	cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


Measured memory_bytes: 6520