import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
#from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)
resm=m
resM=M
c_M=False
c_m=False
ans=[]
for i in range(n):
    if a[i]==M and c_M==False:
        c_M=True
        continue
    elif a[i]==m and c_m==False:
        c_m=True
        continue
    if a[i]>0:
        ans.append((resm,a[i]))
        resm=resm-a[i]
    else:
        ans.append((resM,a[i]))
        resM=resM-a[i]
print(resM-resm)
for i in ans:
    print(*i)
print(resM,resm) import sys sys import math math 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 M=max(a) M max(a) max a m=min(a) m min(a) min a resm=m resm m resM=M resM M c_M=False c_M False c_m=False c_m False ans=[] ans [] for i in range(n):
    if a[i]==M and c_M==False:
        c_M=True
        continue
    elif a[i]==m and c_m==False:
        c_m=True
        continue
    if a[i]>0:
        ans.append((resm,a[i]))
        resm=resm-a[i]
    else:
        ans.append((resM,a[i]))
        resM=resM-a[i] i range(n) range n if a[i]==M and c_M==False:
        c_M=True
        continue
    elif a[i]==m and c_m==False:
        c_m=True
        continue
     a[i]==M and c_M==False a[i]==M a[i] a i M c_M==False c_M False c_M=True c_M True continue elif a[i]==m and c_m==False:
        c_m=True
        continue
     a[i]==m and c_m==False a[i]==m a[i] a i m c_m==False c_m False c_m=True c_m True continue if a[i]>0:
        ans.append((resm,a[i]))
        resm=resm-a[i]
    else:
        ans.append((resM,a[i]))
        resM=resM-a[i] a[i]>0 a[i] a i 0 ans.append((resm,a[i])) ans.append ans append (resm,a[i]) resm a[i] a i resm=resm-a[i] resm resm-a[i] resm a[i] a i ans.append((resM,a[i])) ans.append ans append (resM,a[i]) resM a[i] a i resM=resM-a[i] resM resM-a[i] resM a[i] a i print(resM-resm) print resM-resm resM resm for i in ans:
    print(*i) i ans print(*i) print *i i print(resM,resm) print resM resm resM=M M resM M=max(a) max(a) M resM=resM-a[i] resM-a[i] resM resm=m m resm c_M=False False c_M m=min(a) min(a) m n=int(input()) int(input()) n ans=[] [] ans resm=resm-a[i] resm-a[i] resm a=list(map(int,input().split())) list(map(int,input().split())) a c_m=True True c_m c_m=False False c_m c_M=True True c_M
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
#from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
M=max(a)
m=min(a)
resm=m
resM=M
c_M=False
c_m=False
ans=[]
for i in range(n):
    if a[i]==M and c_M==False:
        c_M=True
        continue
    elif a[i]==m and c_m==False:
        c_m=True
        continue
    if a[i]>0:
        ans.append((resm,a[i]))
        resm=resm-a[i]
    else:
        ans.append((resM,a[i]))
        resM=resM-a[i]
print(resM-resm)
for i in ans:
    print(*i)
print(resM,resm)
