fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map{it.toLong()}.sorted()

    val mn: List<Long>
    val ps: List<Long>

    if (A[0] >= 0) {
        mn = A.take(1)
        ps = A.drop(1)
    } else if (A.last() < 0) {
        mn = A.dropLast(1)
        ps = A.takeLast(1)
    } else {
        mn = A.filter { it < 0 }
        ps = A.filter { it >= 0 }
    }

    println(ps.sum() - mn.sum())

    var t = mn[0]

    for (a in ps.dropLast(1)) {
        println("$t $a")

        t -= a
    }

    println("${ps.last()} $t")

    t = ps.last() - t

    for (a in mn.drop(1)) {
        println("$t $a")
        t -= a
    }
}
