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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

long	get_g(long i, vector<long> &grp) {
	if (i==grp.at(i)) return i;
	return get_g(grp.at(i), grp);
}

int     main() {
	// N: Number of nodes
	// M: Number of links
	long N, M;
	cin >>N >>M;
	vector<vector<long>> a(N, vector<long> (2, 0));
	for (long i=0; i<N; i++) {
		cin >>a.at(i).at(0);
		a.at(i).at(1)=i;
	}
	sort(a.begin(), a.end());
	// Data store
	// p: Original value for each position
	// grp: Group#
	// grp_depth: Steps to the group root
	vector<long> grp(N, 0);
	vector<long> grp_depth(N, 0);
	// Read data for each node
	// Initialize group# as each own
	for (long i=0; i<N; i++)
		grp.at(i)=i;
	// Links
	// Each link connects nodes x and y
	// (Swap rules)
	vector<long> x(M, 0);
	vector<long> y(M, 0);
	for (long i=0; i<M; i++)
		cin >>x.at(i) >>y.at(i);
	// Grouping
	for (long i=0; i<M; i++) {
		long xx=x.at(i);
		long yy=y.at(i);
		xx=get_g(xx, grp);
		yy=get_g(yy, grp);
		// Already in same group, do nothing
		if (xx==yy) continue;
		// Put longo one group
		if (grp_depth.at(xx)==grp_depth.at(yy)) {
			// Groups have same height
			// Merge longo less-number-group
			grp.at(max(xx, yy)) = get_g(min(xx, yy), grp);
			grp_depth.at(min(xx, yy))++;
		} else if (grp_depth.at(xx)>grp_depth.at(yy)) {
			// x is higher
			// Merge longo x so that the hight will not increase
			// (height for y will be +1)
			grp.at(yy) = xx;
		} else
			// y is higher
			// Merget longo y
			grp.at(xx) = yy;
	}
	long S=0;
	long GN=0;
	vector<bool> GLinked(N, true);
	// Get GN & Group List
	for (long i=0; i<N; i++) {
		long gg=get_g(i, grp);
		if (GLinked.at(gg)) {
			GN++;
			GLinked.at(gg)=false;
		}
	}
	if (1==GN) {
		cout <<0 <<endl;
		return 0;
	}
	long L=GN-2;
	for (long i=0; i<N; i++) {
		long gg=get_g(a.at(i).at(1), grp);
		if (GLinked.at(gg)) {
			if (L>0) {
				L--;
				S+=a.at(i).at(0);
			}
		} else {
			GLinked.at(gg)=true;
			S+=a.at(i).at(0);
		}
	}
	if (0!=L) {
		cout <<"Impossible" <<endl;
		return 0;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 8832