from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = []
if min(a)>=0:
    print(sum(a)-2*a[0])
    now = a[0]
    for i in range(n-2):
        print(now, a[i+1])
        now -= a[i+1]
    print(a[-1], now)
elif max(a)<=0:
    print(-sum(a)+2*a[-1])
    now = a[-1]
    for i in range(n-1):
        print(now, a[i])
        now -= a[i]
else:
    idx = bisect_left(a, 0)
    pa = a[idx:]
    na = a[:idx]
    print(sum(pa)-sum(na))
    now = pa[0]
    for i in range(len(na)-1):
        print(now, na[i])
        now -= na[i]
    pa.append(now)
    now = na[-1]
    for i in range(1, len(pa)-1):
        print(now, pa[i])
        now -= pa[i]
    print(pa[-1], now) from bisect import bisect_left 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 ans = [] ans [] if min(a)>=0:
    print(sum(a)-2*a[0])
    now = a[0]
    for i in range(n-2):
        print(now, a[i+1])
        now -= a[i+1]
    print(a[-1], now)
elif max(a)<=0:
    print(-sum(a)+2*a[-1])
    now = a[-1]
    for i in range(n-1):
        print(now, a[i])
        now -= a[i]
else:
    idx = bisect_left(a, 0)
    pa = a[idx:]
    na = a[:idx]
    print(sum(pa)-sum(na))
    now = pa[0]
    for i in range(len(na)-1):
        print(now, na[i])
        now -= na[i]
    pa.append(now)
    now = na[-1]
    for i in range(1, len(pa)-1):
        print(now, pa[i])
        now -= pa[i]
    print(pa[-1], now) min(a)>=0 min(a) min a 0 print(sum(a)-2*a[0]) print sum(a)-2*a[0] sum(a) sum a 2*a[0] 2 a[0] a 0 now = a[0] now a[0] a 0 for i in range(n-2):
        print(now, a[i+1])
        now -= a[i+1]
     i range(n-2) range n-2 n 2 print(now, a[i+1]) print now a[i+1] a i+1 i 1 now -= a[i+1] now a[i+1] a i+1 i 1 print(a[-1], now) print a[-1] a -1 now elif max(a)<=0:
    print(-sum(a)+2*a[-1])
    now = a[-1]
    for i in range(n-1):
        print(now, a[i])
        now -= a[i] max(a)<=0 max(a) max a 0 print(-sum(a)+2*a[-1]) print -sum(a)+2*a[-1] -sum(a) sum(a) sum a 2*a[-1] 2 a[-1] a -1 now = a[-1] now a[-1] a -1 for i in range(n-1):
        print(now, a[i])
        now -= a[i] i range(n-1) range n-1 n 1 print(now, a[i]) print now a[i] a i now -= a[i] now a[i] a i idx = bisect_left(a, 0) idx bisect_left(a, 0) bisect_left a 0 pa = a[idx:] pa a[idx:] a idx: idx na = a[:idx] na a[:idx] a :idx idx print(sum(pa)-sum(na)) print sum(pa)-sum(na) sum(pa) sum pa sum(na) sum na now = pa[0] now pa[0] pa 0 for i in range(len(na)-1):
        print(now, na[i])
        now -= na[i]
     i range(len(na)-1) range len(na)-1 len(na) len na 1 print(now, na[i]) print now na[i] na i now -= na[i] now na[i] na i pa.append(now) pa.append pa append now now = na[-1] now na[-1] na -1 for i in range(1, len(pa)-1):
        print(now, pa[i])
        now -= pa[i]
     i range(1, len(pa)-1) range 1 len(pa)-1 len(pa) len pa 1 print(now, pa[i]) print now pa[i] pa i now -= pa[i] now pa[i] pa i print(pa[-1], now) print pa[-1] pa -1 now ans = [] [] ans now = pa[0] pa[0] now now -= a[i] a[i] now now -= a[i+1] a[i+1] now pa = a[idx:] a[idx:] pa na = a[:idx] a[:idx] na now = na[-1] na[-1] now now = a[-1] a[-1] now now = a[0] a[0] now idx = bisect_left(a, 0) bisect_left(a, 0) idx now -= pa[i] pa[i] now now -= na[i] na[i] now a = list(map(int, input().split())) list(map(int, input().split())) a n = int(input()) int(input()) n
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = []
if min(a)>=0:
    print(sum(a)-2*a[0])
    now = a[0]
    for i in range(n-2):
        print(now, a[i+1])
        now -= a[i+1]
    print(a[-1], now)
elif max(a)<=0:
    print(-sum(a)+2*a[-1])
    now = a[-1]
    for i in range(n-1):
        print(now, a[i])
        now -= a[i]
else:
    idx = bisect_left(a, 0)
    pa = a[idx:]
    na = a[:idx]
    print(sum(pa)-sum(na))
    now = pa[0]
    for i in range(len(na)-1):
        print(now, na[i])
        now -= na[i]
    pa.append(now)
    now = na[-1]
    for i in range(1, len(pa)-1):
        print(now, pa[i])
        now -= pa[i]
    print(pa[-1], now)
