import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.traits;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    auto as = readln.split.to!(long[]);
    auto G = new int[][N];
    foreach (_; 0..M) {
        auto xy = readln.split.to!(int[]);
        auto x = xy[0];
        auto y = xy[1];
        G[x] ~= y;
        G[y] ~= x;
    }
    auto F = new bool[](N);
    alias InQ = ReturnType!(heapify!("a > b", long[]));
    InQ[] out_buf;
    foreach (i; 0..N) {
        if (F[i]) continue;
        F[i] = true;
        auto buf = [as[i], long.max];
        void walk(int i, int p) {
            foreach (j; G[i]) if (j != p && !F[j]) {
                buf ~= as[j];
                F[j] = true;
                walk(j, i);
            }
        }
        walk(i, -1);
        out_buf ~= InQ(buf);
    }
    auto Q = heapify!"a.front > b.front"(out_buf);

    long r;
    while (Q.length > 1) {
        auto a = Q.front;
        Q.removeFront();
        auto b = Q.front;
        Q.removeFront();

        if (a.front == long.max || b.front == long.max) {
            writeln("Impossible");
            return;
        }

        r += a.front + b.front;
        a.removeFront();
        b.removeFront();

        if (a.length < b.length) swap(a, b);
        while (b.front != long.max) {
            a.insert(b.front);
            b.removeFront();
        }
        Q.insert(a);
    }
    writeln(r);
}