N = int(input())
A = [int(s) for s in input().split(' ')]
A.sort()
print(A[N - 1] + sum([abs(a) for a in A[1:N - 1]]) - A[0])
answer = ''
for i in range(1, len(A) - 1):
    if(A[i] > 0):
        answer += "{} {}\n".format(A[0], A[i])
        A[0] -= A[i]
    else:
        answer += "{} {}\n".format(A[N - 1], A[i])
        A[N - 1] -= A[i]
answer += "{} {}\n".format(A[N - 1], A[0])
print(answer) N = int(input()) N int(input()) int input() input int(s) for s in input().split(' ') for s in input().split(' ') s input().split(' ') ().split () input split ' ' for s in input().split(' ') int(s) int s A = [int(s) for s in input().split(' ')] A [int(s) for s in input().split(' ')] A.sort() A.sort A sort abs(a) for a in A[1:N - 1] for a in A[1:N - 1] a A[1:N - 1] A 1:N - 1 1 N - 1 N 1 for a in A[1:N - 1] abs(a) abs a print(A[N - 1] + sum([abs(a) for a in A[1:N - 1]]) - A[0]) print A[N - 1] + sum([abs(a) for a in A[1:N - 1]]) - A[0] A[N - 1] + sum([abs(a) for a in A[1:N - 1]]) A[N - 1] A N - 1 N 1 sum([abs(a) for a in A[1:N - 1]]) sum [abs(a) for a in A[1:N - 1]] A[0] A 0 answer = '' answer '' for i in range(1, len(A) - 1):
    if(A[i] > 0):
        answer += "{} {}\n".format(A[0], A[i])
        A[0] -= A[i]
    else:
        answer += "{} {}\n".format(A[N - 1], A[i])
        A[N - 1] -= A[i] i range(1, len(A) - 1) range 1 len(A) - 1 len(A) len A 1 if(A[i] > 0):
        answer += "{} {}\n".format(A[0], A[i])
        A[0] -= A[i]
    else:
        answer += "{} {}\n".format(A[N - 1], A[i])
        A[N - 1] -= A[i] A[i] > 0 A[i] A i 0 answer += "{} {}\n".format(A[0], A[i]) answer "{} {}\n".format(A[0], A[i]) "{} {}\n".format "{} {}\n" format A[0] A 0 A[i] A i A[0] -= A[i] A[0] A 0 A[i] A i answer += "{} {}\n".format(A[N - 1], A[i]) answer "{} {}\n".format(A[N - 1], A[i]) "{} {}\n".format "{} {}\n" format A[N - 1] A N - 1 N 1 A[i] A i A[N - 1] -= A[i] A[N - 1] A N - 1 N 1 A[i] A i answer += "{} {}\n".format(A[N - 1], A[0]) answer "{} {}\n".format(A[N - 1], A[0]) "{} {}\n".format "{} {}\n" format A[N - 1] A N - 1 N 1 A[0] A 0 print(answer) print answer A = [int(s) for s in input().split(' ')] [int(s) for s in input().split(' ')] A answer = '' '' answer answer += "{} {}\n".format(A[N - 1], A[0]) "{} {}\n".format(A[N - 1], A[0]) answer answer += "{} {}\n".format(A[N - 1], A[i]) "{} {}\n".format(A[N - 1], A[i]) answer N = int(input()) int(input()) N answer += "{} {}\n".format(A[0], A[i]) "{} {}\n".format(A[0], A[i]) answer
N = int(input())
A = [int(s) for s in input().split(' ')]
A.sort()
print(A[N - 1] + sum([abs(a) for a in A[1:N - 1]]) - A[0])
answer = ''
for i in range(1, len(A) - 1):
    if(A[i] > 0):
        answer += "{} {}\n".format(A[0], A[i])
        A[0] -= A[i]
    else:
        answer += "{} {}\n".format(A[N - 1], A[i])
        A[N - 1] -= A[i]
answer += "{} {}\n".format(A[N - 1], A[0])
print(answer)