n=int(input())
a=sorted(list(map(int,input().split())))
max=a[-1]
min=a[0]
if n==2:
    print(max-min)
    print(max,min)
    exit()
ans=0
if a[-1]<0:
    ans+=-sum(a)+max*2
elif a[0]>0:
    ans+=sum(a)-min*2
else:
    for x in a:
        ans+=abs(x)
print(ans)
X=max
Y=min
for i in range(1,n-1):
    if a[i]>=0:
        x=Y
        y=a[i]
        print(x,y)
        Y=x-y    
    else:
        x=X
        y=a[i]
        print(x,y)
        X=x-y
print(X,Y) n=int(input()) n int(input()) int input() input a=sorted(list(map(int,input().split()))) a sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split max=a[-1] max a[-1] a -1 min=a[0] min a[0] a 0 if n==2:
    print(max-min)
    print(max,min)
    exit() n==2 n 2 print(max-min) print max-min max min print(max,min) print max min exit() exit ans=0 ans 0 if a[-1]<0:
    ans+=-sum(a)+max*2
elif a[0]>0:
    ans+=sum(a)-min*2
else:
    for x in a:
        ans+=abs(x) a[-1]<0 a[-1] a -1 0 ans+=-sum(a)+max*2 ans -sum(a)+max*2 -sum(a) sum(a) sum a max*2 max 2 elif a[0]>0:
    ans+=sum(a)-min*2 a[0]>0 a[0] a 0 0 ans+=sum(a)-min*2 ans sum(a)-min*2 sum(a) sum a min*2 min 2 for x in a:
        ans+=abs(x) x a ans+=abs(x) ans abs(x) abs x print(ans) print ans X=max X max Y=min Y min for i in range(1,n-1):
    if a[i]>=0:
        x=Y
        y=a[i]
        print(x,y)
        Y=x-y    
    else:
        x=X
        y=a[i]
        print(x,y)
        X=x-y i range(1,n-1) range 1 n-1 n 1 if a[i]>=0:
        x=Y
        y=a[i]
        print(x,y)
        Y=x-y    
    else:
        x=X
        y=a[i]
        print(x,y)
        X=x-y a[i]>=0 a[i] a i 0 x=Y x Y y=a[i] y a[i] a i print(x,y) print x y Y=x-y Y x-y x y x=X x X y=a[i] y a[i] a i print(x,y) print x y X=x-y X x-y x y print(X,Y) print X Y ans+=sum(a)-min*2 sum(a)-min*2 ans X=max max X x=X X x X=x-y x-y X max=a[-1] a[-1] max n=int(input()) int(input()) n Y=min min Y y=a[i] a[i] y ans+=-sum(a)+max*2 -sum(a)+max*2 ans a=sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) a Y=x-y x-y Y ans=0 0 ans y=a[i] a[i] y min=a[0] a[0] min ans+=abs(x) abs(x) ans x=Y Y x
n=int(input())
a=sorted(list(map(int,input().split())))
max=a[-1]
min=a[0]
if n==2:
    print(max-min)
    print(max,min)
    exit()
ans=0
if a[-1]<0:
    ans+=-sum(a)+max*2
elif a[0]>0:
    ans+=sum(a)-min*2
else:
    for x in a:
        ans+=abs(x)
print(ans)
X=max
Y=min
for i in range(1,n-1):
    if a[i]>=0:
        x=Y
        y=a[i]
        print(x,y)
        Y=x-y    
    else:
        x=X
        y=a[i]
        print(x,y)
        X=x-y
print(X,Y)
