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