import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;


void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!long).array;
    auto uf = new UnionFind(N, A);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int);
        uf.unite(s[0], s[1]);
    }


    auto pq1 = new BinaryHeap!(Array!(long[]), "a[0] > b[0]");
    auto pq2 = new BinaryHeap!(Array!(long[]), "a[0] > b[0]");
    foreach (i; 0..N) {
        if (uf.group[i].length == 1) {
            auto a = uf.group[i].dup;
            pq1.insert(a);
        } else if (uf.group[i].length > 1) {
            auto a = uf.group[i].dup;
            a.sort();
            pq2.insert(a);
        }
    }

    long ans = 0;

    while (pq1.length + pq2.length > 1) {
        long[] t1, t2;
        if (pq1.length == 0) {
            t1 = pq2.front; pq2.removeFront;
            t2 = pq2.front; pq2.removeFront;
        } else if (pq2.length == 0) {
            if (pq1.length > 2) {
                writeln("Impossible");
                return;
            }
            t1 = pq1.front; pq1.removeFront;
            t2 = pq1.front; pq1.removeFront;
        } else if (pq1.front.front <= pq2.front.front) {
            t1 = pq1.front; pq1.removeFront;
            t2 = pq2.front; pq2.removeFront;
        } else {
            t1 = pq2.front; pq2.removeFront;
            if (pq1.front.front <= pq2.front.front) {
                t2 = pq1.front; pq1.removeFront;
            } else {
                t2 = pq2.front; pq2.removeFront;
            }
        }

        ans += t1.front + t2.front;
        auto new_a = merge(t1[1..$], t2[1..$]);
        if (new_a.length == 1) {
            pq1.insert(new_a);
        } else {
            pq2.insert(new_a);
        }
    }

    ans.writeln;
}

long[] merge(long[] a, long[] b) {
    long[] ret;
    for (int i = 0, j = 0; i < a.length || j < b.length; ) {
        if (i >= a.length) {
            ret ~= b[j];
            j += 1;
        } else if (j >= b.length) {
            ret ~= a[i];
            i += 1;
        } else if (a[i] <= b[j]) {
            ret ~= a[i];
            i += 1;
        } else {
            ret ~= b[j];
            j += 1;
        }
    }
    return ret;
}

class UnionFind {
    int N;
    int[] table;
    long[][] group;

    this(int n, long[] a) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        group = new long[][](N);
        foreach (i; 0..N) group[i] = [a[i]];
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
        group[x] ~= group[y];
        group[y] = [];
    }
}
