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