import java.util.Stack

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val weights = readLine()!!.split(" ").map(String::toLong)
    val mutableGraph = Array(n, { mutableListOf<Int>() })
    for (i in 0 until m) {
        val (x, y) = readLine()!!.split(" ").map(String::toInt)
        mutableGraph[x].add(y)
        mutableGraph[y].add(x)
    }
    val graph = mutableGraph.map { it.toList() }
    val cc = getCC(graph)
    // println(cc)

    val numCC = cc.max()!! + 1
    if (n < 2 * numCC - 2) {
        println("Impossible")
        return
    }
    if (numCC == 1) {
        println(0)
        return
    }

    val mutableCCIdToWeights = Array(numCC, { mutableListOf<Long>() })
    for (v in 0 until n) {
        mutableCCIdToWeights[cc[v]].add(weights[v])
    }
    mutableCCIdToWeights.forEach { it.sort() }

    var total = 0L
    val remainings = mutableListOf<Long>()
    for (ccWeights in mutableCCIdToWeights) {
        total += ccWeights[0]
        remainings.addAll(ccWeights.subList(1, ccWeights.size))
    }
    remainings.sort()
    total += remainings.subList(0, numCC - 2).sum()
    println(total)
}

fun getCC(graph: List<List<Int>>): List<Int> {
    val n = graph.size
    val cc = IntArray(n, { -1 })

    var currentId = 0
    for (k in 0 until n) {
        if (cc[k] >= 0) continue
        cc[k] = currentId
        val stack = Stack<Int>()
        stack.push(k)
        while (stack.isNotEmpty()) {
            val v = stack.pop()
            for (w in graph[v]) {
                if (cc[w] < 0) {
                    cc[w] = currentId
                    stack.push(w)
                }
            }
        }
        currentId++
    }
    return cc.asList()
}