N = int(input())
A = list(map(int,input().split()))

S = sum(map(abs,A))

if all([a>0 for a in A]):
    print(S-2*min(A))
    A = sorted(A)
    B = [A[0]]
    for i in range(1,N):
        B.append(B[-1]-A[i])
    for i in range(N-2):
        print(B[i],A[i+1])
    print(A[N-1],B[N-2])

elif all([a<0 for a in A]):
    print(S+2*max(A))
    A = sorted(A)
    B = [A[-1]]
    for i in range(N-1):
        B.append(B[-1]-A[i])
    for i in range(N-1):
        print(B[i],A[i])

else:
    print(S)
    A = sorted(A)
    B = [A[0]]
    for i in range(N):
        if N-1-2-i<0 or A[-2-i]<0:
            print(A[-1-i],B[-1])
            B.append(A[-1-i]-B[-1])
            break
        print(B[-1],A[-1-i])
        B.append(B[-1]-A[-1-i])
    C = [B[-1]]
    for i in range(1,N):
        if A[i]>=0:
            break
        print(C[-1],A[i])
        C.append(C[-1]-A[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 S = sum(map(abs,A)) S sum(map(abs,A)) sum map(abs,A) map abs A if all([a>0 for a in A]):
    print(S-2*min(A))
    A = sorted(A)
    B = [A[0]]
    for i in range(1,N):
        B.append(B[-1]-A[i])
    for i in range(N-2):
        print(B[i],A[i+1])
    print(A[N-1],B[N-2])

elif all([a<0 for a in A]):
    print(S+2*max(A))
    A = sorted(A)
    B = [A[-1]]
    for i in range(N-1):
        B.append(B[-1]-A[i])
    for i in range(N-1):
        print(B[i],A[i])

else:
    print(S)
    A = sorted(A)
    B = [A[0]]
    for i in range(N):
        if N-1-2-i<0 or A[-2-i]<0:
            print(A[-1-i],B[-1])
            B.append(A[-1-i]-B[-1])
            break
        print(B[-1],A[-1-i])
        B.append(B[-1]-A[-1-i])
    C = [B[-1]]
    for i in range(1,N):
        if A[i]>=0:
            break
        print(C[-1],A[i])
        C.append(C[-1]-A[i]) all([a>0 for a in A]) all [a>0 for a in A] print(S-2*min(A)) print S-2*min(A) S 2*min(A) 2 min(A) min A A = sorted(A) A sorted(A) sorted A B = [A[0]] B [A[0]] A[0] A 0 for i in range(1,N):
        B.append(B[-1]-A[i])
     i range(1,N) range 1 N B.append(B[-1]-A[i]) B.append B append B[-1]-A[i] B[-1] B -1 A[i] A i for i in range(N-2):
        print(B[i],A[i+1])
     i range(N-2) range N-2 N 2 print(B[i],A[i+1]) print B[i] B i A[i+1] A i+1 i 1 print(A[N-1],B[N-2]) print A[N-1] A N-1 N 1 B[N-2] B N-2 N 2 elif all([a<0 for a in A]):
    print(S+2*max(A))
    A = sorted(A)
    B = [A[-1]]
    for i in range(N-1):
        B.append(B[-1]-A[i])
    for i in range(N-1):
        print(B[i],A[i]) all([a<0 for a in A]) all [a<0 for a in A] print(S+2*max(A)) print S+2*max(A) S 2*max(A) 2 max(A) max A A = sorted(A) A sorted(A) sorted A B = [A[-1]] B [A[-1]] A[-1] A -1 for i in range(N-1):
        B.append(B[-1]-A[i])
     i range(N-1) range N-1 N 1 B.append(B[-1]-A[i]) B.append B append B[-1]-A[i] B[-1] B -1 A[i] A i for i in range(N-1):
        print(B[i],A[i]) i range(N-1) range N-1 N 1 print(B[i],A[i]) print B[i] B i A[i] A i print(S) print S A = sorted(A) A sorted(A) sorted A B = [A[0]] B [A[0]] A[0] A 0 for i in range(N):
        if N-1-2-i<0 or A[-2-i]<0:
            print(A[-1-i],B[-1])
            B.append(A[-1-i]-B[-1])
            break
        print(B[-1],A[-1-i])
        B.append(B[-1]-A[-1-i])
     i range(N) range N if N-1-2-i<0 or A[-2-i]<0:
            print(A[-1-i],B[-1])
            B.append(A[-1-i]-B[-1])
            break
         N-1-2-i<0 or A[-2-i]<0 N-1-2-i<0 N-1-2-i N-1-2 N-1 N 1 2 i 0 A[-2-i]<0 A[-2-i] A -2-i -2 i 0 print(A[-1-i],B[-1]) print A[-1-i] A -1-i -1 i B[-1] B -1 B.append(A[-1-i]-B[-1]) B.append B append A[-1-i]-B[-1] A[-1-i] A -1-i -1 i B[-1] B -1 break print(B[-1],A[-1-i]) print B[-1] B -1 A[-1-i] A -1-i -1 i B.append(B[-1]-A[-1-i]) B.append B append B[-1]-A[-1-i] B[-1] B -1 A[-1-i] A -1-i -1 i C = [B[-1]] C [B[-1]] B[-1] B -1 for i in range(1,N):
        if A[i]>=0:
            break
        print(C[-1],A[i])
        C.append(C[-1]-A[i]) i range(1,N) range 1 N if A[i]>=0:
            break
         A[i]>=0 A[i] A i 0 break print(C[-1],A[i]) print C[-1] C -1 A[i] A i C.append(C[-1]-A[i]) C.append C append C[-1]-A[i] C[-1] C -1 A[i] A i S = sum(map(abs,A)) sum(map(abs,A)) S B = [A[0]] [A[0]] B A = list(map(int,input().split())) list(map(int,input().split())) A A = sorted(A) sorted(A) A N = int(input()) int(input()) N C = [B[-1]] [B[-1]] C B = [A[-1]] [A[-1]] B A = sorted(A) sorted(A) A A = sorted(A) sorted(A) A B = [A[0]] [A[0]] B
N = int(input())
A = list(map(int,input().split()))

S = sum(map(abs,A))

if all([a>0 for a in A]):
    print(S-2*min(A))
    A = sorted(A)
    B = [A[0]]
    for i in range(1,N):
        B.append(B[-1]-A[i])
    for i in range(N-2):
        print(B[i],A[i+1])
    print(A[N-1],B[N-2])

elif all([a<0 for a in A]):
    print(S+2*max(A))
    A = sorted(A)
    B = [A[-1]]
    for i in range(N-1):
        B.append(B[-1]-A[i])
    for i in range(N-1):
        print(B[i],A[i])

else:
    print(S)
    A = sorted(A)
    B = [A[0]]
    for i in range(N):
        if N-1-2-i<0 or A[-2-i]<0:
            print(A[-1-i],B[-1])
            B.append(A[-1-i]-B[-1])
            break
        print(B[-1],A[-1-i])
        B.append(B[-1]-A[-1-i])
    C = [B[-1]]
    for i in range(1,N):
        if A[i]>=0:
            break
        print(C[-1],A[i])
        C.append(C[-1]-A[i])