n = int(input())
A = list(map(int, input().split()))
A.sort()
u, d = A[-1], A[0]
print(sum(abs(a) for a in A) - 2*min(abs(u), abs(d))*int(u*d>0))
for a in A[1:-1]:
    if a<0:
        print(u, a)
        u -= a
    else:
        print(d, a)
        d -= a
print(u, d) n = int(input()) n int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split A.sort() A.sort A sort u, d = A[-1], A[0] u A[-1] A -1 d A[0] A 0 print(sum(abs(a) for a in A) - 2*min(abs(u), abs(d))*int(u*d>0)) print sum(abs(a) for a in A) - 2*min(abs(u), abs(d))*int(u*d>0) sum(abs(a) for a in A) sum abs(a) abs a 2*min(abs(u), abs(d))*int(u*d>0) 2*min(abs(u), abs(d)) 2 min(abs(u), abs(d)) min abs(u) abs u abs(d) abs d int(u*d>0) int u*d>0 u*d u d 0 for a in A[1:-1]:
    if a<0:
        print(u, a)
        u -= a
    else:
        print(d, a)
        d -= a a A[1:-1] A 1:-1 1 -1 if a<0:
        print(u, a)
        u -= a
    else:
        print(d, a)
        d -= a a<0 a 0 print(u, a) print u a u -= a u a print(d, a) print d a d -= a d a print(u, d) print u d u, d = A[-1], A[0] A[-1] u d = A[-1], A[0] A[0] d n = int(input()) int(input()) n A = list(map(int, input().split())) list(map(int, input().split())) A u -= a a u d -= a a d
n = int(input())
A = list(map(int, input().split()))
A.sort()
u, d = A[-1], A[0]
print(sum(abs(a) for a in A) - 2*min(abs(u), abs(d))*int(u*d>0))
for a in A[1:-1]:
    if a<0:
        print(u, a)
        u -= a
    else:
        print(d, a)
        d -= a
print(u, d)