#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

struct UnionFind { // {{{
    vector<int> u;
    explicit UnionFind(int n): u(n+5, -1) {}
    int  size(int x)        { return -u[root(x)]; }
    int  root(int x)        { return (u[x] < 0)? x : (u[x] = root(u[x])); }
    bool same(int x, int y) { return (root(x) == root(y)); }
    bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
}; // }}}

template <class T>
using CustomCompHeap = priority_queue<T, vector<T>, function<bool(T, T)>>;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N, M;
    read(N, M);

    vector<int> w(N);
    rep(i, N) {
        read(w[i]);
    }

    UnionFind uf(N);
    rep(i, M) {
        int u, v;
        read(u, v);
        uf.unite(u, v);
    }

    const int treeCnt = N - M;
    const int needNodeCnt = (treeCnt - 1) * 2;

    if (treeCnt == 1) {
        print(0);
        return 0;
    }
    if (needNodeCnt > N) {
        print("Impossible");
        return 0;
    }

    const auto compareNodeByWeight = [&w](int u, int v) -> bool {
        return w[u] > w[v];
    };

    vector<CustomCompHeap<int>> trees(N, CustomCompHeap<int>(compareNodeByWeight));

    rep(i, N) {
        const int treeID = uf.root(i);
        trees[treeID].push(i);
    }

    i64 ans = 0;
    CustomCompHeap<int> rest(compareNodeByWeight);
    rep(i, N) if (not trees[i].empty()) {
        auto &tree = trees[i];
        const int v = tree.top(); tree.pop();
        ans += w[v];

        while (not tree.empty()) {
            rest.push(tree.top());
            tree.pop();
        }
    }

    rep(i, needNodeCnt - treeCnt) {
        const int v = rest.top(); rest.pop();
        ans += w[v];
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 8704