import sys
import itertools
import collections
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
a = lmi()
a.sort()
b = [-1 for i in range(n)]
b[-1] = 1
for i in range(1, n-1):
    if a[i] > 0:
        b[i] = 1


print(sum([a[i]*b[i] for i in range(n)]))

x = a[0]
for y in [a[i] for i in range(n-1) if b[i] == 1]:
    print(x, y)
    x -= y

y = x
x = a[-1]
print(x, y)
x -= y
for y in [a[i] for i in range(1,n-1) if b[i] == -1]:
    print(x, y)
    x -= y import sys sys import itertools itertools import collections collections sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 def lmi(): return list(map(int, input().split())) lmi n = int(input()) n int(input()) int input() input a = lmi() a lmi() lmi a.sort() a.sort a sort -1 for i in range(n) for i in range(n) i range(n) range n for i in range(n) -1 b = [-1 for i in range(n)] b [-1 for i in range(n)] b[-1] = 1 b[-1] b -1 1 for i in range(1, n-1):
    if a[i] > 0:
        b[i] = 1 i range(1, n-1) range 1 n-1 n 1 if a[i] > 0:
        b[i] = 1 a[i] > 0 a[i] a i 0 b[i] = 1 b[i] b i 1 a[i]*b[i] for i in range(n) for i in range(n) i range(n) range n for i in range(n) a[i]*b[i] a[i] a i b[i] b i print(sum([a[i]*b[i] for i in range(n)])) print sum([a[i]*b[i] for i in range(n)]) sum [a[i]*b[i] for i in range(n)] x = a[0] x a[0] a 0 for y in [a[i] for i in range(n-1) if b[i] == 1]:
    print(x, y)
    x -= y y [a[i] for i in range(n-1) if b[i] == 1] print(x, y) print x y x -= y x y y = x y x x = a[-1] x a[-1] a -1 print(x, y) print x y x -= y x y for y in [a[i] for i in range(1,n-1) if b[i] == -1]:
    print(x, y)
    x -= y y [a[i] for i in range(1,n-1) if b[i] == -1] print(x, y) print x y x -= y x y x = a[0] a[0] x def lmi(): return list(map(int, input().split())) def lmi(): return list(map(int, input().split())) lmi b = [-1 for i in range(n)] [-1 for i in range(n)] b y = x x y x = a[-1] a[-1] x n = int(input()) int(input()) n x -= y y x x -= y y x a = lmi() lmi() a x -= y y x
import sys
import itertools
import collections
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
a = lmi()
a.sort()
b = [-1 for i in range(n)]
b[-1] = 1
for i in range(1, n-1):
    if a[i] > 0:
        b[i] = 1


print(sum([a[i]*b[i] for i in range(n)]))

x = a[0]
for y in [a[i] for i in range(n-1) if b[i] == 1]:
    print(x, y)
    x -= y

y = x
x = a[-1]
print(x, y)
x -= y
for y in [a[i] for i in range(1,n-1) if b[i] == -1]:
    print(x, y)
    x -= y
