import java.util.ArrayDeque
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val AList = readInputLine().split(" ").map { it.toInt() }.sorted()
    val absSum = AList.sumBy { Math.abs(it) }
    val deque = ArrayDeque<Int>(N)
    
    for (a in AList) {
        deque.addLast(a)
    }
    
    val first = deque.peekFirst()
    val last = deque.peekLast()
    
    if (last < 0) {
        println(absSum - last * -2)
        println("$last $first")
        deque.pollFirst()
        deque.pollLast()
        deque.addLast(last - first)
    } else if (first > 0) {
        println(absSum - first * 2)
        println("$first $last")
        deque.pollFirst()
        deque.pollLast()
        deque.addFirst(first - last)
    } else {
        println(absSum)
    }
    
    if (deque.size == 1) {
        return
    }
    
    while (deque.size > 2) {
        val first = deque.pollFirst()
        val last = deque.pollLast()
        
        if (deque.peekFirst() >= 0) {
            println("$first $last")
            deque.addFirst(first - last)
        } else {
            println("$last $first")
            deque.addLast(last - first)
        }
    }
    
    println("${deque.pollLast()} ${deque.pollLast()}")
}

fun readInputLine(): String {
    return readLine()!!
}
