let N = Int(readLine()!)!
var A = readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
var ans = [String]()
for i in (1..<N).reverse() {
    var (x, y) = (A.first!, A.last!)
    A.removeAtIndex(A.startIndex)
    A.removeAtIndex(A.endIndex.predecessor())
    if i%2 > 0 {
        (x, y) = (y, x)
        A = A + [x-y]
    } else {
        A = [x-y] + A
    }
    ans += ["\(x) \(y)"]
}
print(A[0])
ans.forEach{print($0)}