from bisect import bisect_left

N = int(input())
*A, = map(int, input().split())
A.sort()

if A[0]<=0 and A[-1]<=0:
    ans = sum(map(abs, A[:-1]))+A[-1]
    A.reverse()

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a>b else (b, a)
        t.append((x, y))
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]

elif A[0]>=0 and A[-1]>=0:
    ans = sum(A[1:])-A[0]

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a<b else (b, a)
        t.append((x, y))
        
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]
    a, b = t[-1]
    t[-1] = (b, a)


else:
    ans = sum(map(abs, A))
    p = bisect_left(A, 0)
    t = []
    s = []

    a = A[p-1]
    for i in range(p, N-1):
        b = A[i]
        t.append((a, b))
        a = a - b
        
    c = A[N-1]
    for i in ([a]+A[:p-1]):
        t.append((c, i))
        c = c-i

print(ans)
for i in t:
    print(*i) from bisect import bisect_left N = int(input()) N int(input()) int input() input *A, = map(int, input().split()) *A A map(int, input().split()) map int input().split() ().split () input split A.sort() A.sort A sort if A[0]<=0 and A[-1]<=0:
    ans = sum(map(abs, A[:-1]))+A[-1]
    A.reverse()

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a>b else (b, a)
        t.append((x, y))
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]

elif A[0]>=0 and A[-1]>=0:
    ans = sum(A[1:])-A[0]

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a<b else (b, a)
        t.append((x, y))
        
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]
    a, b = t[-1]
    t[-1] = (b, a)


else:
    ans = sum(map(abs, A))
    p = bisect_left(A, 0)
    t = []
    s = []

    a = A[p-1]
    for i in range(p, N-1):
        b = A[i]
        t.append((a, b))
        a = a - b
        
    c = A[N-1]
    for i in ([a]+A[:p-1]):
        t.append((c, i))
        c = c-i A[0]<=0 and A[-1]<=0 A[0]<=0 A[0] A 0 0 A[-1]<=0 A[-1] A -1 0 ans = sum(map(abs, A[:-1]))+A[-1] ans sum(map(abs, A[:-1]))+A[-1] sum(map(abs, A[:-1])) sum map(abs, A[:-1]) map abs A[:-1] A :-1 -1 A[-1] A -1 A.reverse() A.reverse A reverse r = 1 r 1 a, b = A[0], A[1] a A[0] A 0 b A[1] A 1 t = [] t [] while 1:
        x, y = (a, b) if a>b else (b, a)
        t.append((x, y))
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r] 1 x, y = (a, b) if a>b else (b, a) x (a, b) if a>b else (b, a) a>b a b (a, b) a b (b, a) b a y t.append((x, y)) t.append t append (x, y) x y r += 1 r 1 if not r<N:
            break
         not r<N r<N r N break a, b = x-y, A[r] a x-y x y b A[r] A r elif A[0]>=0 and A[-1]>=0:
    ans = sum(A[1:])-A[0]

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a<b else (b, a)
        t.append((x, y))
        
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]
    a, b = t[-1]
    t[-1] = (b, a) A[0]>=0 and A[-1]>=0 A[0]>=0 A[0] A 0 0 A[-1]>=0 A[-1] A -1 0 ans = sum(A[1:])-A[0] ans sum(A[1:])-A[0] sum(A[1:]) sum A[1:] A 1: 1 A[0] A 0 r = 1 r 1 a, b = A[0], A[1] a A[0] A 0 b A[1] A 1 t = [] t [] while 1:
        x, y = (a, b) if a<b else (b, a)
        t.append((x, y))
        
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]
     1 x, y = (a, b) if a<b else (b, a) x (a, b) if a<b else (b, a) a<b a b (a, b) a b (b, a) b a y t.append((x, y)) t.append t append (x, y) x y r += 1 r 1 if not r<N:
            break
         not r<N r<N r N break a, b = x-y, A[r] a x-y x y b A[r] A r a, b = t[-1] a t[-1] t -1 b t[-1] = (b, a) t[-1] t -1 (b, a) b a ans = sum(map(abs, A)) ans sum(map(abs, A)) sum map(abs, A) map abs A p = bisect_left(A, 0) p bisect_left(A, 0) bisect_left A 0 t = [] t [] s = [] s [] a = A[p-1] a A[p-1] A p-1 p 1 for i in range(p, N-1):
        b = A[i]
        t.append((a, b))
        a = a - b
        
     i range(p, N-1) range p N-1 N 1 b = A[i] b A[i] A i t.append((a, b)) t.append t append (a, b) a b a = a - b a a - b a b c = A[N-1] c A[N-1] A N-1 N 1 for i in ([a]+A[:p-1]):
        t.append((c, i))
        c = c-i i [a]+A[:p-1] [a] a A[:p-1] A :p-1 p-1 p 1 t.append((c, i)) t.append t append (c, i) c i c = c-i c c-i c i print(ans) print ans for i in t:
    print(*i) i t print(*i) print *i i b = A[i] A[i] b a, b = x-y, A[r] x-y a x, y = (a, b) if a<b else (b, a) (a, b) if a<b else (b, a) x c = A[N-1] A[N-1] c r += 1 1 r t = [] [] t p = bisect_left(A, 0) bisect_left(A, 0) p r += 1 1 r x, y = (a, b) if a>b else (b, a) (a, b) if a>b else (b, a) x a = a - b a - b a t = [] [] t c = c-i c-i c a, b = t[-1] t[-1] a ans = sum(map(abs, A[:-1]))+A[-1] sum(map(abs, A[:-1]))+A[-1] ans ans = sum(map(abs, A)) sum(map(abs, A)) ans r = 1 1 r r = 1 1 r b = A[0], A[1] A[1] b b = A[0], A[1] A[1] b b = x-y, A[r] A[r] b a, b = A[0], A[1] A[0] a b = x-y, A[r] A[r] b a = A[p-1] A[p-1] a b = t[-1] t[-1] b N = int(input()) int(input()) N y = (a, b) if a>b else (b, a) (a, b) if a>b else (b, a) y a, b = A[0], A[1] A[0] a a, b = x-y, A[r] x-y a y = (a, b) if a<b else (b, a) (a, b) if a<b else (b, a) y ans = sum(A[1:])-A[0] sum(A[1:])-A[0] ans t = [] [] t s = [] [] s
from bisect import bisect_left

N = int(input())
*A, = map(int, input().split())
A.sort()

if A[0]<=0 and A[-1]<=0:
    ans = sum(map(abs, A[:-1]))+A[-1]
    A.reverse()

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a>b else (b, a)
        t.append((x, y))
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]

elif A[0]>=0 and A[-1]>=0:
    ans = sum(A[1:])-A[0]

    r = 1
    a, b = A[0], A[1]
    t = []
    
    while 1:
        x, y = (a, b) if a<b else (b, a)
        t.append((x, y))
        
        r += 1
        if not r<N:
            break
        a, b = x-y, A[r]
    a, b = t[-1]
    t[-1] = (b, a)


else:
    ans = sum(map(abs, A))
    p = bisect_left(A, 0)
    t = []
    s = []

    a = A[p-1]
    for i in range(p, N-1):
        b = A[i]
        t.append((a, b))
        a = a - b
        
    c = A[N-1]
    for i in ([a]+A[:p-1]):
        t.append((c, i))
        c = c-i

print(ans)
for i in t:
    print(*i)