let N = Int(readLine()!)!
var A = readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
var ans = [(Int, Int)]()
for i in 0..<N-2 {
    ans += [(A[i], A[i+1])]
    A[i+1] = A[i] - A[i+1]
}
print(A[N-2] - A[N-1])
ans += [(A[N-2], A[N-1])]
ans.forEach{print($0.0, $0.1)}