from collections import deque

n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
p = 0
b = 0

qp = deque([])
qn = deque([])

for i in range(n):
    b += abs(a[i])
    if a[i] < 0:
        qn.append(a[i])
        p += 1
    else:
        qp.append(a[i])
if p != 0 and p != n:
    print(b)
    for i in range(n-2):
        if len(qp) >= 2:
            x = qn.popleft()
            y = qp.popleft()
            print(x,y)
            qn.append(x-y)
        else:
            x = qn.popleft()
            y = qp.popleft()
            print(y,x)
            qp.append(y-x)
    if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
    
elif p == 0:
    print(b-2*a[0])
    x = qp.popleft()
    y = qp.pop()
    print(x,y)
    qn.append(x-y)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(x,y)
        qn.append(x-y)
    if len(qp) == 1 and len(qn) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
    
else:
    print(b-2*abs(a[-1]))
    x = qn.popleft()
    y = qn.pop()
    print(y,x)
    qp.append(y-x)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
        qp.append(y-x)
    if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x) from collections import deque 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 = sorted(a) a sorted(a) sorted a p = 0 p 0 b = 0 b 0 qp = deque([]) qp deque([]) deque [] qn = deque([]) qn deque([]) deque [] for i in range(n):
    b += abs(a[i])
    if a[i] < 0:
        qn.append(a[i])
        p += 1
    else:
        qp.append(a[i]) i range(n) range n b += abs(a[i]) b abs(a[i]) abs a[i] a i if a[i] < 0:
        qn.append(a[i])
        p += 1
    else:
        qp.append(a[i]) a[i] < 0 a[i] a i 0 qn.append(a[i]) qn.append qn append a[i] a i p += 1 p 1 qp.append(a[i]) qp.append qp append a[i] a i if p != 0 and p != n:
    print(b)
    for i in range(n-2):
        if len(qp) >= 2:
            x = qn.popleft()
            y = qp.popleft()
            print(x,y)
            qn.append(x-y)
        else:
            x = qn.popleft()
            y = qp.popleft()
            print(y,x)
            qp.append(y-x)
    if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
    
elif p == 0:
    print(b-2*a[0])
    x = qp.popleft()
    y = qp.pop()
    print(x,y)
    qn.append(x-y)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(x,y)
        qn.append(x-y)
    if len(qp) == 1 and len(qn) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
    
else:
    print(b-2*abs(a[-1]))
    x = qn.popleft()
    y = qn.pop()
    print(y,x)
    qp.append(y-x)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
        qp.append(y-x)
    if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x) p != 0 and p != n p != 0 p 0 p != n p n print(b) print b for i in range(n-2):
        if len(qp) >= 2:
            x = qn.popleft()
            y = qp.popleft()
            print(x,y)
            qn.append(x-y)
        else:
            x = qn.popleft()
            y = qp.popleft()
            print(y,x)
            qp.append(y-x)
     i range(n-2) range n-2 n 2 if len(qp) >= 2:
            x = qn.popleft()
            y = qp.popleft()
            print(x,y)
            qn.append(x-y)
        else:
            x = qn.popleft()
            y = qp.popleft()
            print(y,x)
            qp.append(y-x)
     len(qp) >= 2 len(qp) len qp 2 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(x,y) print x y qn.append(x-y) qn.append qn append x-y x y x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(y,x) print y x qp.append(y-x) qp.append qp append y-x y x if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
     len(qn) == 1 and len(qp) == 1 len(qn) == 1 len(qn) len qn 1 len(qp) == 1 len(qp) len qp 1 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(y,x) print y x elif p == 0:
    print(b-2*a[0])
    x = qp.popleft()
    y = qp.pop()
    print(x,y)
    qn.append(x-y)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(x,y)
        qn.append(x-y)
    if len(qp) == 1 and len(qn) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
     p == 0 p 0 print(b-2*a[0]) print b-2*a[0] b 2*a[0] 2 a[0] a 0 x = qp.popleft() x qp.popleft() qp.popleft qp popleft y = qp.pop() y qp.pop() qp.pop qp pop print(x,y) print x y qn.append(x-y) qn.append qn append x-y x y for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(x,y)
        qn.append(x-y)
     i range(n-3) range n-3 n 3 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(x,y) print x y qn.append(x-y) qn.append qn append x-y x y if len(qp) == 1 and len(qn) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
     len(qp) == 1 and len(qn) == 1 len(qp) == 1 len(qp) len qp 1 len(qn) == 1 len(qn) len qn 1 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(y,x) print y x print(b-2*abs(a[-1])) print b-2*abs(a[-1]) b 2*abs(a[-1]) 2 abs(a[-1]) abs a[-1] a -1 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qn.pop() y qn.pop() qn.pop qn pop print(y,x) print y x qp.append(y-x) qp.append qp append y-x y x for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
        qp.append(y-x)
     i range(n-3) range n-3 n 3 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(y,x) print y x qp.append(y-x) qp.append qp append y-x y x if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x) len(qn) == 1 and len(qp) == 1 len(qn) == 1 len(qn) len qn 1 len(qp) == 1 len(qp) len qp 1 x = qn.popleft() x qn.popleft() qn.popleft qn popleft y = qp.popleft() y qp.popleft() qp.popleft qp popleft print(y,x) print y x p += 1 1 p x = qn.popleft() qn.popleft() x y = qp.popleft() qp.popleft() y a = list(map(int,input().split())) list(map(int,input().split())) a x = qn.popleft() qn.popleft() x y = qp.popleft() qp.popleft() y y = qp.popleft() qp.popleft() y p = 0 0 p b = 0 0 b y = qn.pop() qn.pop() y y = qp.popleft() qp.popleft() y x = qn.popleft() qn.popleft() x y = qp.popleft() qp.popleft() y qp = deque([]) deque([]) qp y = qp.popleft() qp.popleft() y n = int(input()) int(input()) n b += abs(a[i]) abs(a[i]) b x = qp.popleft() qp.popleft() x y = qp.popleft() qp.popleft() y x = qn.popleft() qn.popleft() x qn = deque([]) deque([]) qn x = qn.popleft() qn.popleft() x x = qn.popleft() qn.popleft() x y = qp.pop() qp.pop() y a = sorted(a) sorted(a) a x = qn.popleft() qn.popleft() x x = qn.popleft() qn.popleft() x
from collections import deque

n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
p = 0
b = 0

qp = deque([])
qn = deque([])

for i in range(n):
    b += abs(a[i])
    if a[i] < 0:
        qn.append(a[i])
        p += 1
    else:
        qp.append(a[i])
if p != 0 and p != n:
    print(b)
    for i in range(n-2):
        if len(qp) >= 2:
            x = qn.popleft()
            y = qp.popleft()
            print(x,y)
            qn.append(x-y)
        else:
            x = qn.popleft()
            y = qp.popleft()
            print(y,x)
            qp.append(y-x)
    if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
    
elif p == 0:
    print(b-2*a[0])
    x = qp.popleft()
    y = qp.pop()
    print(x,y)
    qn.append(x-y)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(x,y)
        qn.append(x-y)
    if len(qp) == 1 and len(qn) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
    
else:
    print(b-2*abs(a[-1]))
    x = qn.popleft()
    y = qn.pop()
    print(y,x)
    qp.append(y-x)
    for i in range(n-3):
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)
        qp.append(y-x)
    if len(qn) == 1 and len(qp) == 1:
        x = qn.popleft()
        y = qp.popleft()
        print(y,x)