N = int(input())
A = list(map(int,input().split()))
p,n = 0,0
Positive,Negative = [],[]
ans = []
for i in range(N):
    if A[i] >= 0:
        p += 1
        Positive.append(A[i])
    else:
        n += 1
        Negative.append(A[i])
Positive.sort()
Negative.sort()
if n == 0:
    now = Positive[0]
    for i in range(1,N-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    ans.append((Positive[N-1],now))
    Positive[N-1] -= now
    print(Positive[N-1])
    for i in range(len(ans)):
        print(*ans[i])
elif n >= 1 and p >= 1:
    now = Negative[0]
    for i in range(p-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    bigM = now
    now = Positive[-1]
    for i in range(1,n):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    bigP = now
    ans.append((bigP,bigM))
    bigP -= bigM
    print(bigP)
    for i in range(len(ans)):
        print(*ans[i])
else:
    now = Negative[-1]
    for i in range(N-1):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    print(now)
    for i in range(len(ans)):
        print(*ans[i]) 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 p,n = 0,0 p 0 n 0 Positive,Negative = [],[] Positive [] Negative [] ans = [] ans [] for i in range(N):
    if A[i] >= 0:
        p += 1
        Positive.append(A[i])
    else:
        n += 1
        Negative.append(A[i]) i range(N) range N if A[i] >= 0:
        p += 1
        Positive.append(A[i])
    else:
        n += 1
        Negative.append(A[i]) A[i] >= 0 A[i] A i 0 p += 1 p 1 Positive.append(A[i]) Positive.append Positive append A[i] A i n += 1 n 1 Negative.append(A[i]) Negative.append Negative append A[i] A i Positive.sort() Positive.sort Positive sort Negative.sort() Negative.sort Negative sort if n == 0:
    now = Positive[0]
    for i in range(1,N-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    ans.append((Positive[N-1],now))
    Positive[N-1] -= now
    print(Positive[N-1])
    for i in range(len(ans)):
        print(*ans[i])
elif n >= 1 and p >= 1:
    now = Negative[0]
    for i in range(p-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    bigM = now
    now = Positive[-1]
    for i in range(1,n):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    bigP = now
    ans.append((bigP,bigM))
    bigP -= bigM
    print(bigP)
    for i in range(len(ans)):
        print(*ans[i])
else:
    now = Negative[-1]
    for i in range(N-1):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    print(now)
    for i in range(len(ans)):
        print(*ans[i]) n == 0 n 0 now = Positive[0] now Positive[0] Positive 0 for i in range(1,N-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
     i range(1,N-1) range 1 N-1 N 1 ans.append((now,Positive[i])) ans.append ans append (now,Positive[i]) now Positive[i] Positive i now -= Positive[i] now Positive[i] Positive i ans.append((Positive[N-1],now)) ans.append ans append (Positive[N-1],now) Positive[N-1] Positive N-1 N 1 now Positive[N-1] -= now Positive[N-1] Positive N-1 N 1 now print(Positive[N-1]) print Positive[N-1] Positive N-1 N 1 for i in range(len(ans)):
        print(*ans[i]) i range(len(ans)) range len(ans) len ans print(*ans[i]) print *ans[i] ans[i] ans i elif n >= 1 and p >= 1:
    now = Negative[0]
    for i in range(p-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    bigM = now
    now = Positive[-1]
    for i in range(1,n):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    bigP = now
    ans.append((bigP,bigM))
    bigP -= bigM
    print(bigP)
    for i in range(len(ans)):
        print(*ans[i]) n >= 1 and p >= 1 n >= 1 n 1 p >= 1 p 1 now = Negative[0] now Negative[0] Negative 0 for i in range(p-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
     i range(p-1) range p-1 p 1 ans.append((now,Positive[i])) ans.append ans append (now,Positive[i]) now Positive[i] Positive i now -= Positive[i] now Positive[i] Positive i bigM = now bigM now now = Positive[-1] now Positive[-1] Positive -1 for i in range(1,n):
        ans.append((now,Negative[i]))
        now -= Negative[i]
     i range(1,n) range 1 n ans.append((now,Negative[i])) ans.append ans append (now,Negative[i]) now Negative[i] Negative i now -= Negative[i] now Negative[i] Negative i bigP = now bigP now ans.append((bigP,bigM)) ans.append ans append (bigP,bigM) bigP bigM bigP -= bigM bigP bigM print(bigP) print bigP for i in range(len(ans)):
        print(*ans[i]) i range(len(ans)) range len(ans) len ans print(*ans[i]) print *ans[i] ans[i] ans i now = Negative[-1] now Negative[-1] Negative -1 for i in range(N-1):
        ans.append((now,Negative[i]))
        now -= Negative[i]
     i range(N-1) range N-1 N 1 ans.append((now,Negative[i])) ans.append ans append (now,Negative[i]) now Negative[i] Negative i now -= Negative[i] now Negative[i] Negative i print(now) print now for i in range(len(ans)):
        print(*ans[i]) i range(len(ans)) range len(ans) len ans print(*ans[i]) print *ans[i] ans[i] ans i ans = [] [] ans now = Negative[-1] Negative[-1] now Positive,Negative = [],[] [] Positive N = int(input()) int(input()) N now = Positive[0] Positive[0] now now = Positive[-1] Positive[-1] now now = Negative[0] Negative[0] now Negative = [],[] [] Negative p += 1 1 p now -= Negative[i] Negative[i] now n = 0,0 0 n now -= Negative[i] Negative[i] now now -= Positive[i] Positive[i] now bigP = now now bigP p,n = 0,0 0 p n += 1 1 n A = list(map(int,input().split())) list(map(int,input().split())) A bigP -= bigM bigM bigP now -= Positive[i] Positive[i] now bigM = now now bigM
N = int(input())
A = list(map(int,input().split()))
p,n = 0,0
Positive,Negative = [],[]
ans = []
for i in range(N):
    if A[i] >= 0:
        p += 1
        Positive.append(A[i])
    else:
        n += 1
        Negative.append(A[i])
Positive.sort()
Negative.sort()
if n == 0:
    now = Positive[0]
    for i in range(1,N-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    ans.append((Positive[N-1],now))
    Positive[N-1] -= now
    print(Positive[N-1])
    for i in range(len(ans)):
        print(*ans[i])
elif n >= 1 and p >= 1:
    now = Negative[0]
    for i in range(p-1):
        ans.append((now,Positive[i]))
        now -= Positive[i]
    bigM = now
    now = Positive[-1]
    for i in range(1,n):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    bigP = now
    ans.append((bigP,bigM))
    bigP -= bigM
    print(bigP)
    for i in range(len(ans)):
        print(*ans[i])
else:
    now = Negative[-1]
    for i in range(N-1):
        ans.append((now,Negative[i]))
        now -= Negative[i]
    print(now)
    for i in range(len(ans)):
        print(*ans[i])