#include <cassert>
#include <cstddef>
#include <numeric>
#include <utility>
#include <vector>

class UnionFind {

public:
	using size_type = std::size_t;
	using container_type = std::vector<size_type>;

protected:
	container_type p, s;

public:
	UnionFind() : p(), s() {}
	explicit UnionFind(const size_type size)
		: p(size), s(size, static_cast<size_type>(1)) {
		std::iota(p.begin(), p.end(), static_cast<size_type>(0));
	}

	size_type size() const { return p.size(); }
	bool empty() const { return p.empty(); }

	size_type find(size_type x) {
		assert(x < size());
		while (p[x] != x)
			x = p[x] = p[p[x]];
		return x;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return s[find(x)];
	}

	::std::pair<size_type,size_type> unite(size_type x, size_type y) {
		assert(x < size());
		assert(y < size());
		x = find(x);
		y = find(y);
		if (x != y) {
			if (s[x] < s[y])
				std::swap(x, y);
			s[x] += s[y];
			p[y] = x;
		}
		return { x,y };
	}
};

#include <cassert>
#include <cstddef>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>

template <class T, class Compare = ::std::less_equal<T>> class pairing_heap {

public:
	using value_type = T;
	using const_reference = const value_type &;
	using size_type = ::std::size_t;
	using value_compare = Compare;

private:
	struct node_type {
		value_type value;
		::std::unique_ptr<node_type> left, right;
		template <class... Args>
		node_type(Args &&... args)
			: value(::std::forward<Args>(args)...), left(), right() {}
	};
	using pointer = ::std::unique_ptr<node_type>;
	pointer root;
	value_compare comp;
	size_type s;
	pointer merge(pointer x, pointer y) {
		if (!x)
			return ::std::move(y);
		if (!y)
			return ::std::move(x);
		if (!comp(x->value, y->value))
			x.swap(y);
		y->right = ::std::move(x->left);
		x->left = ::std::move(y);
		return ::std::move(x);
	}
	pointer mergelist(pointer curr) {
		pointer head, temp, next;
		while (curr) {
			next = ::std::move(curr->right);
			if (next) {
				temp = ::std::move(next->right);
				curr = merge(::std::move(curr), ::std::move(next));
			}
			curr->right = ::std::move(head);
			head = ::std::move(curr);
			curr = ::std::move(temp);
		}
		while (head) {
			next = ::std::move(head->right);
			curr = merge(::std::move(curr), ::std::move(head));
			head = ::std::move(next);
		}
		return ::std::move(curr);
	}

public:
	pairing_heap() : root(), comp(), s(0) {}
	explicit pairing_heap(const value_compare &x) : root(), comp(x), s(0) {}

	bool empty() const noexcept { return !root; }
	size_type size() const noexcept { return s; }

	const_reference top() const noexcept {
		assert(!empty());
		return root->value;
	}

	void push(const value_type &x) {
		root = merge(::std::move(root), ::std::make_unique<node_type>(x));
		++s;
	}
	void push(value_type &&x) {
		root = merge(::std::move(root), ::std::make_unique<node_type>(::std::move(x)));
		++s;
	}
	template <class... Args> void emplace(Args &&... args) {
		root = merge(::std::move(root),
			::std::make_unique<node_type>(::std::forward<Args>(args)...));
		++s;
	}

	void pop() {
		assert(!empty());
		root = mergelist(::std::move(root->left));
		--s;
	}

	void meld(pairing_heap &x) {
		s += x.s;
		x.s = 0;
		root = merge(::std::move(root), ::std::move(x.root));
	}
	pairing_heap &operator+=(pairing_heap &x) {
		meld(x);
		return *this;
	}
};


#include<iostream>
#include<tuple>
#include<vector>
int main(void) {
	int n, m;
	::std::cin >> n >> m;
	::std::vector<pairing_heap<int>> Q(n);
	UnionFind T(n);
	for (int i = 0; i < n; ++i) {
		int a;
		::std::cin >> a;
		Q[i].push(a);
	}
	for (int i = 0; i < m; ++i) {
		int x, y;
		::std::cin >> x >> y;
		int r, c;
		::std::tie(r, c) = T.unite(x, y);
		Q[r].meld(Q[c]);
	}
	::std::vector<UnionFind::size_type> R;
	for (int i = 0;i < n;++i)
		if (T.find(i) == i)
			R.emplace_back(i);
	if (R.size() == 1) {
		::std::cout << "0" << ::std::endl;
		return 0;
	}
	long long cost = 0;
	pairing_heap<int> P;
	for (const auto i : R) {
		cost += Q[i].top();
		Q[i].pop();
		P.meld(Q[i]);
	}
	if (P.size() + 2 < R.size()) {
		::std::cout << "Impossible" << ::std::endl;
		return 0;
	}
	for (int i = 2; i < R.size(); ++i)
		cost += P.top(), P.pop();
	::std::cout << cost << ::std::endl;
	return 0;
}


Measured memory_bytes: 8440