#include <cassert>
#include <cstddef>
#include <utility>

template <template <class> class Container> class union_find {
protected:
	class node_type;

public:
	using container_type = Container<node_type>;
	using size_type = typename container_type::size_type;

protected:
	class node_type {
	public:
		typename union_find::size_type parent, size;
	};
	container_type c;

public:
	union_find() : c() {}
	explicit union_find(const size_type size) : c(size, { 0, 1 }) {
		for (size_type i = 0; i < size; ++i)
			c[i].parent = i;
	}

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

	size_type find(size_type x) {
		assert(x < size());
		while (c[x].parent != x)
			x = c[x].parent = c[c[x].parent].parent;
		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 c[find(x)].size;
	}

	::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 (c[x].size < c[y].size)
				::std::swap(x, y);
			c[x].size += c[y].size;
			c[y].parent = x;
		}
		return { x, y };
	}
};

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

template <class TotallyOrderedSet> class pairing_heap {

public:
	using value_structure = TotallyOrderedSet;
	using value_type = typename value_structure::value_type;
	using const_reference = const value_type &;
	using size_type = ::std::size_t;

private:
	class node_type {
	public:
		value_type value;
		::std::pair<::std::unique_ptr<node_type>, ::std::unique_ptr<node_type>>
			child;
		template <class... Args>
		node_type(Args &&... args)
			: value(::std::forward<Args>(args)...), child() {}
	};
	using pointer = ::std::unique_ptr<node_type>;
	pointer root;
	size_type s;
	static pointer merge(pointer x, pointer y) {
		if (!x)
			return y;
		if (!y)
			return x;
		if (!value_structure::operation(x->value, y->value))
			x.swap(y);
		y->child.second = ::std::move(x->child.first);
		x->child.first = ::std::move(y);
		return x;
	}
	static pointer mergelist(pointer curr) {
		pointer head, temp, next;
		while (curr) {
			next = ::std::move(curr->child.second);
			if (next) {
				temp = ::std::move(next->child.second);
				curr = merge(::std::move(curr), ::std::move(next));
			}
			curr->child.second = ::std::move(head);
			head = ::std::move(curr);
			curr = ::std::move(temp);
		}
		if (head) {
			curr = ::std::move(head);
			head = ::std::move(curr->child.second);
		}
		while (head) {
			next = ::std::move(head->child.second);
			curr = merge(::std::move(curr), ::std::move(head));
			head = ::std::move(next);
		}
		return curr;
	}

public:
	pairing_heap() noexcept : root(), 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->child.first));
		--s;
	}

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

template <class T> class forward_order_set {
public:
	using value_type = T;
	static bool operation(const value_type &x, const value_type &y) {
		return x <= y;
	}
};


#include<iostream>
#include<tuple>
#include<vector>

template<class T>
using vec = ::std::vector<T>;

int main(void) {
	int n, m;
	::std::cin >> n >> m;
	::std::vector<pairing_heap<forward_order_set<int>>> Q(n);
	union_find<vec> 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;
		::std::tie(x, y) = T.unite(x, y);
		if (x != y)
			Q[x].meld(Q[y]);
	}
	::std::vector<union_find<vec>::size_type> R;
	for (int i = 0;i < n;++i)
		if (T.find(i) == i)
			R.push_back(i);
	if (R.size() == 1) {
		::std::cout << "0" << ::std::endl;
		return 0;
	}
	long long cost = 0;
	pairing_heap<forward_order_set<int>> P;
	for (const auto i : R) {
		cost += Q[i].top();
		Q[i].pop();
		P += 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: 7672