import Foundation
let rdInt = Int(readLine()!)!
let rdArr = readLine()!.split(separator: " ").map({Int($0)!}).sorted{$0 > $1}
var aliceArr = [Int]()
var bobArr = [Int]()
for i in 1 ..< rdInt {
    aliceArr.append(rdArr[2*(i-1)])
    bobArr.append(rdArr[2*i-1])
    if rdInt.isMultiple(of: 2) {
        bobArr.removeLast()
    }
}
print(aliceArr)
print(bobArr)
print(aliceArr.reduce(0, +) - bobArr.reduce(0,+))