import sys


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -10 ** 20
    for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
    print(DP[N-1][1])
    flip = N
    for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
    sumA = A[0]
    for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
    print(A[N-1], sumA)
    sumA = A[N-1] - sumA
    for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

    return 0

if __name__ == "__main__":
    solve() import sys sys def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -10 ** 20
    for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
    print(DP[N-1][1])
    flip = N
    for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
    sumA = A[0]
    for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
    print(A[N-1], sumA)
    sumA = A[N-1] - sumA
    for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

    return 0 solve input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input int(a) for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a A = [int(a) for a in input().split()] A [int(a) for a in input().split()] A.sort() A.sort A sort [None, None] for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) [None, None] None None DP = [[None, None] for _ in range(N)] DP [[None, None] for _ in range(N)] DP[0][0] = -A[0] DP[0][0] [0] DP 0 0 -A[0] A[0] A 0 DP[0][1] = -10 ** 20 DP[0][1] [0] DP 0 1 -10 ** 20 -10 20 for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
     i range(1, N) range 1 N DP[i][0] = DP[i-1][0] - A[i] DP[i][0] [i] DP i 0 DP[i-1][0] - A[i] DP[i-1][0] [i-1] DP i-1 i 1 0 A[i] A i DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i]) DP[i][1] [i] DP i 1 max(DP[i-1][1] + A[i], DP[i-1][0] + A[i]) max DP[i-1][1] + A[i] DP[i-1][1] [i-1] DP i-1 i 1 1 A[i] A i DP[i-1][0] + A[i] DP[i-1][0] [i-1] DP i-1 i 1 0 A[i] A i print(DP[N-1][1]) print DP[N-1][1] [N-1] DP N-1 N 1 1 flip = N flip N for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
     i reversed(range(1, N)) reversed range(1, N) range 1 N if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
     DP[i][1] - DP[i-1][1] != A[i] DP[i][1] - DP[i-1][1] DP[i][1] [i] DP i 1 DP[i-1][1] [i-1] DP i-1 i 1 1 A[i] A i flip = i flip i break sumA = A[0] sumA A[0] A 0 for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
     i range(flip, N-1) range flip N-1 N 1 print(sumA, A[i]) print sumA A[i] A i sumA -= A[i] sumA A[i] A i print(A[N-1], sumA) print A[N-1] A N-1 N 1 sumA sumA = A[N-1] - sumA sumA A[N-1] - sumA A[N-1] A N-1 N 1 sumA for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

     i range(1, flip) range 1 flip print(sumA, A[i]) print sumA A[i] A i sumA -= A[i] sumA A[i] A i return 0 0 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -10 ** 20
    for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
    print(DP[N-1][1])
    flip = N
    for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
    sumA = A[0]
    for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
    print(A[N-1], sumA)
    sumA = A[N-1] - sumA
    for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

    return 0 def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -10 ** 20
    for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
    print(DP[N-1][1])
    flip = N
    for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
    sumA = A[0]
    for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
    print(A[N-1], sumA)
    sumA = A[N-1] - sumA
    for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

    return 0 solve
import sys


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -10 ** 20
    for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
    print(DP[N-1][1])
    flip = N
    for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
    sumA = A[0]
    for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
    print(A[N-1], sumA)
    sumA = A[N-1] - sumA
    for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

    return 0

if __name__ == "__main__":
    solve()