//#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

static constexpr double PI = 3.1415926535897932;

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

class UnionFindTree {
	using int32 = std::int_fast32_t;
	using uint32 = std::uint_fast32_t;
	std::vector<int32> tree;

public:
	UnionFindTree(uint32 size) : tree(size, -1) {}
	uint32 find(const uint32 x) {
		if (tree[x] < 0)
			return x;
		return tree[x] = (int32)find((uint32)tree[x]);
	}
	bool unite(uint32 x, uint32 y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x] > tree[y])
			std::swap(x, y);
		tree[x] += tree[y];
		tree[y] = (int32)x;
		return true;
	}
	uint32 size(const uint32 x) { return (uint32)(-tree[find(x)]); }
	bool same(const uint32 x, const uint32 y) { return find(x) == find(y); }
	std::vector<uint32> roots() const {
		std::vector<uint32> ret;
		for (uint32 i = 0; i < tree.size(); ++i) {
			if (tree[i] < 0)
				ret.push_back(i);
		}
		return ret;
	}
};

template <typename T, bool P = false> class PairingHeap {
	static constexpr std::uint_fast64_t ALLOCSIZE = (std::uint_fast64_t)1 << 10;

public:
	struct node_t {
		T data;
		node_t *left, *right, *per;
	};

private:
	node_t *root;
	std::uint_fast32_t size_;
	static node_t *merge(node_t *x, node_t *y) {
		if (P ^ (x->data < y->data))
			std::swap(x, y);
		if (x->right = y->left)
			y->left->per = x;
		y->left = x;
		x->per = y;
		return y;
	}

public:
	PairingHeap() : root(nullptr), size_(0) {}
	const T &top() const {
		assert(root);
		return root->data;
	}
	const T &pop() {
		assert(root);
		--size_;
		const T &ret = root->data;
		node_t *n = nullptr, *x = root->left, *y;
		while (x) {
			y = x;
			if (x->right) {
				x = x->right->right;
				y = merge(y, y->right);
			}
			else {
				x = nullptr;
			}
			y->right = n;
			n = y;
		}
		if (!n) {
			root = nullptr;
			return ret;
		}
		root = n;
		n = n->right;
		while (n) {
			x = n;
			n = n->right;
			root = merge(root, x);
		}
		root->per = nullptr;
		root->right = nullptr;
		return ret;
	}
	const node_t *push(const T &data) {
		static node_t *pool = nullptr;
		static std::uint_fast64_t it = ALLOCSIZE;
		if (it == ALLOCSIZE) {
			pool = (node_t *)malloc(ALLOCSIZE * sizeof(node_t));
			it = 0;
		}
		node_t *top = &pool[it++];
		top->data = data;
		top->left = top->right = top->per = nullptr;
		root = root ? merge(root, top) : top;
		++size_;
		return top;
	}
	bool empty() { return !root; }
	std::uint_fast32_t size() { return size_; }
	void meld(PairingHeap<T, P> &other) {
		size_ += other.size_;
		other.size_ = 0;
		if (other.root) {
			root = root ? merge(root, other.root) : other.root;
			other.root = nullptr;
		}
	}
	void decrease(node_t *const x, const T &data) {
		assert(x);
		assert(!(P ^ (x->data < data)));
		if (!x->per) {
			x->data = data;
			return;
		}
		if (x->right)
			x->right->per = x->per;
		if (x->per->right != x)
			x->per->left = x->right;
		else
			x->per->right = x->right;
		x->per = nullptr;
		x->right = nullptr;
		root = merge(root, x);
	}
};

int main(void) {
	uint32 n, m;
	std::cin >> n >> m;
	std::vector<PairingHeap<uint32>> Q(n);
	UnionFindTree T(n);
	for (uint32 i = 0; i < n; ++i) {
		uint32 a;
		std::cin >> a;
		Q[i].push(a);
	}
	for (uint32 i = 0; i < m; ++i) {
		uint32 x, y;
		std::cin >> x >> y;
		uint32 xr = T.find(x), yr = T.find(y);
		if (T.unite(x, y)) {
			if (xr == T.find(x))
				Q[xr].meld(Q[yr]);
			else
				Q[yr].meld(Q[xr]);
		}
	}
	std::vector<uint32> R = T.roots();
	if (R.size() == 1) {
		std::cout << "0\n";
		return 0;
	}
	uint64 cost = 0;
	PairingHeap<uint32> P;
	for (const uint32 i : R) {
		cost += Q[i].pop();
		P.meld(Q[i]);
	}
	if (P.size() + 2 < R.size()) {
		std::cout << "Impossible\n";
		return 0;
	}
	for (uint32 i = 2; i < R.size(); ++i)
		cost += P.pop();
	std::cout << cost << "\n";
	return 0;
}

Measured memory_bytes: 6904