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

struct UFTree(T)
{
    struct Node
    {
        T parent;
        T rank = 1;
    }

    ///
    this(T n)
    {
        nodes.length = n;
        sizes.length = n;
        foreach (i, ref node; nodes) {
            node = Node(i.to!T);
            sizes[i] = 1;
        }
    }

    ///
    bool unite(T a, T b)
    {
        a = root(a);
        b = root(b);

        if (a == b) return false;

        if (nodes[a].rank < nodes[b].rank) {
            sizes[nodes[a].parent] += sizes[nodes[b].parent];
            nodes[b].parent = nodes[a].parent;
        } else {
            sizes[nodes[b].parent] += sizes[nodes[a].parent];
            nodes[a].parent = nodes[b].parent;
            if (nodes[a].rank == nodes[b].rank) nodes[a].rank += 1;
        }

        return true;
    }

    ///
    bool is_same(T a, T b)
    {
        return root(a) == root(b);
    }

    ///
    T size(T i)
    {
        return sizes[root(i)];
    }

    T size()
    {
        bool[T] memo;
        foreach (i; 0..this.nodes.length) {
            memo[root(i.to!T)] = true;
        }
        T cnt;
        foreach (_; memo) ++cnt;
        return cnt;
    }

private:
    Node[] nodes;
    T[] sizes;

    T root(T i)
    {
        if (nodes[i].parent == i) return i;

        return nodes[i].parent = root(nodes[i].parent);
    }
}

///
UFTree!T uftree(T)(T n)
{
    return UFTree!T(n);
}

alias Cost = Tuple!(int, "i", long, "a");
Cost[10^^5] CS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (i, a; readln.split.to!(long[])) {
        CS[i] = Cost(i.to!int, a);
    }
    sort!"a.a < b.a"(CS[0..N]);

    auto uftree = uftree(N);

    foreach (_; 0..M) {
        auto xy = readln.split.to!(int[]);
        uftree.unite(xy[0], xy[1]);
    }

    int i, j = 1;
    long r;
    while (j < N) {
        while (i < N && CS[i].a < 0) ++i;
        while (j < N && (CS[j].a < 0 || j <= i)) ++j;
        if (j == N) break;

        if (uftree.is_same(CS[i].i, CS[j].i)) {
            ++j;
        } else {
            uftree.unite(CS[i].i, CS[j].i);
            r += CS[i].a + CS[j].a;
            CS[i].a = -1;
            CS[j].a = -1;
            ++i;
            j = i+1;
        }
    }

    if (uftree.size() == 1) {
        writeln(r);
    } else {
        writeln("Impossible");
    }
}