#解説参照
#構成が無理
#テストどうやってんだろ
n = int(input())
a = list(map(int, input().split( )))

a.sort()
from bisect import bisect_left

j = bisect_left(a,0)
if j==0:
    j+=1
elif j==n:
    j-=1
print(sum(a[j:])-sum(a[:j]))
for i in range(j,n-1):
    print(a[0],a[i])
    a[0]-=a[i]

for i in range(j):
    print(a[-1],a[i])
    a[-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 a.sort() a.sort a sort from bisect import bisect_left j = bisect_left(a,0) j bisect_left(a,0) bisect_left a 0 if j==0:
    j+=1
elif j==n:
    j-=1 j==0 j 0 j+=1 j 1 elif j==n:
    j-=1 j==n j n j-=1 j 1 print(sum(a[j:])-sum(a[:j])) print sum(a[j:])-sum(a[:j]) sum(a[j:]) sum a[j:] a j: j sum(a[:j]) sum a[:j] a :j j for i in range(j,n-1):
    print(a[0],a[i])
    a[0]-=a[i] i range(j,n-1) range j n-1 n 1 print(a[0],a[i]) print a[0] a 0 a[i] a i a[0]-=a[i] a[0] a 0 a[i] a i for i in range(j):
    print(a[-1],a[i])
    a[-1]-=a[i] i range(j) range j print(a[-1],a[i]) print a[-1] a -1 a[i] a i a[-1]-=a[i] a[-1] a -1 a[i] a i j+=1 1 j j = bisect_left(a,0) bisect_left(a,0) j n = int(input()) int(input()) n a = list(map(int, input().split( ))) list(map(int, input().split( ))) a j-=1 1 j
#解説参照
#構成が無理
#テストどうやってんだろ
n = int(input())
a = list(map(int, input().split( )))

a.sort()
from bisect import bisect_left

j = bisect_left(a,0)
if j==0:
    j+=1
elif j==n:
    j-=1
print(sum(a[j:])-sum(a[:j]))
for i in range(j,n-1):
    print(a[0],a[i])
    a[0]-=a[i]

for i in range(j):
    print(a[-1],a[i])
    a[-1]-=a[i]
