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

alias X = Tuple!(int, "g", long, "a");

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);
    X[] xs;
    int len;
    foreach (i; 0..N) {
        if (F[i]) continue;
        F[i] = true;
        xs ~= X(len, as[i]);
        void walk(int i) {
            foreach (j; G[i]) if (!F[j]) {
                xs ~= X(len, as[j]);
                F[j] = true;
                walk(j);
            }
        }
        walk(i);
        ++len;
    }
    if (len == 1) {
        writeln(0);
        return;
    }
    sort!"a.a < b.a"(xs);
    auto cs = new long[][len];
    int filled, cnt;
    X[] ys;
    foreach (x; xs) {
        if (cs[x.g].empty) filled += 1;
        cs[x.g] ~= x.a;
        ys ~= x;
        if (++cnt >= (len-1)*2 && filled == len) break;
    }
    if (cnt < (len-1)*2) {
        writeln("Impossible");
        return;
    }
    foreach_reverse (x; ys) {
        if (cnt == (len-1)*2) break;
        if (cs[x.g].length == 1) continue;
        cs[x.g] = cs[x.g][0..$-1];
        --cnt;
    }
    long r;
    foreach (ref c; cs) foreach (ref a; c) r += a;
    writeln(r);
}