#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
p = min(max(1, p), n - 1)
print(sum(a[p:]) - sum(a[:p]))
b = a[p - 1]
for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i]
c = a[n - 1]
for i in range(p - 1):
    print(c, a[i])
    c -= a[i]
print(c, b) import bisect bisect n = int(input()) n int(input()) int input() input a = sorted(map(int, input().split())) a sorted(map(int, input().split())) sorted map(int, input().split()) map int input().split() ().split () input split if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit() n == 2 n 2 print(a[1] - a[0]) print a[1] - a[0] a[1] a 1 a[0] a 0 print(a[1], a[0]) print a[1] a 1 a[0] a 0 exit() exit p = bisect.bisect_left(a, 0) p bisect.bisect_left(a, 0) bisect.bisect_left bisect bisect_left a 0 p = min(max(1, p), n - 1) p min(max(1, p), n - 1) min max(1, p) max 1 p n - 1 n 1 print(sum(a[p:]) - sum(a[:p])) print sum(a[p:]) - sum(a[:p]) sum(a[p:]) sum a[p:] a p: p sum(a[:p]) sum a[:p] a :p p b = a[p - 1] b a[p - 1] a p - 1 p 1 for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i] i range(p, n - 1) range p n - 1 n 1 print(b, a[i]) print b a[i] a i b -= a[i] b a[i] a i c = a[n - 1] c a[n - 1] a n - 1 n 1 for i in range(p - 1):
    print(c, a[i])
    c -= a[i] i range(p - 1) range p - 1 p 1 print(c, a[i]) print c a[i] a i c -= a[i] c a[i] a i print(c, b) print c b b -= a[i] a[i] b n = int(input()) int(input()) n a = sorted(map(int, input().split())) sorted(map(int, input().split())) a c = a[n - 1] a[n - 1] c c -= a[i] a[i] c p = bisect.bisect_left(a, 0) bisect.bisect_left(a, 0) p b = a[p - 1] a[p - 1] b p = min(max(1, p), n - 1) min(max(1, p), n - 1) p
#!/usr/bin/env python3
import bisect
n = int(input())
a = sorted(map(int, input().split()))
if n == 2:
    print(a[1] - a[0])
    print(a[1], a[0])
    exit()

p = bisect.bisect_left(a, 0)
p = min(max(1, p), n - 1)
print(sum(a[p:]) - sum(a[:p]))
b = a[p - 1]
for i in range(p, n - 1):
    print(b, a[i])
    b -= a[i]
c = a[n - 1]
for i in range(p - 1):
    print(c, a[i])
    c -= a[i]
print(c, b)
