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