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 ones = new BinaryHeap!(Array!long, "a > b");
    auto pq = new BinaryHeap!(Array!(BinaryHeap!(Array!long, "a > b")*), "a.front > b.front");
    
    foreach (i; 0..N) {
        if (uf.group[i].length == 1) {
            ones.insert(uf.group[i].front);
        } else if (uf.group[i].length > 1) {
            auto p = new BinaryHeap!(Array!long, "a > b");
            foreach (a; uf.group[i]) p.insert(a);
            pq.insert(p);
        }
    }

    
    long ans = 0;

    while (ones.length + pq.length > 1) {
        if (ones.length > 2 && pq.length == 0) {
            writeln("Impossible");
            return;
        } else if (pq.length == 0) {
            ans += ones.front; ones.removeFront;
            ans += ones.front; ones.removeFront;
        } else if (ones.length > 0) {
            auto t = pq.front; pq.removeFront;
            ans += t.front + ones.front;
            t.removeFront;
            ones.removeFront;
            if (t.length == 1) {
                ones.insert(t.front);
            } else {
                pq.insert(t);
            }
        } else {
            auto t1 = pq.front; pq.removeFront;
            auto t2 = pq.front; pq.removeFront;
            ans += t1.front + t2.front;
            t1.removeFront;
            t2.removeFront;
            if (t1.length <= t2.length) {
                swap(t1, t2);
            }
            while (!t2.empty) {
                t1.insert(t2.front);
                t2.removeFront;
            }
            pq.insert(t1);
        }
    }

    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] = [];
    }
}
