import bisect
n = int(input())
a = list(map(int, input().split()))

a.sort()
ope = []
max_num = a[-1]
min_num = a[0]
p = bisect.bisect_left(a, 0)
for i in range(1, min(p, n - 1)):
    ope.append([max_num, a[i]])
    max_num -= a[i]
for i in range(max(p, 1), n - 1):
    ope.append([min_num, a[i]])
    min_num -= a[i]
ope.append([max_num, min_num])
print(max_num - min_num)
for i in range(n - 1):
    print(" ".join(map(str, ope[i]))) import bisect bisect 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 ope = [] ope [] max_num = a[-1] max_num a[-1] a -1 min_num = a[0] min_num a[0] a 0 p = bisect.bisect_left(a, 0) p bisect.bisect_left(a, 0) bisect.bisect_left bisect bisect_left a 0 for i in range(1, min(p, n - 1)):
    ope.append([max_num, a[i]])
    max_num -= a[i] i range(1, min(p, n - 1)) range 1 min(p, n - 1) min p n - 1 n 1 ope.append([max_num, a[i]]) ope.append ope append [max_num, a[i]] max_num a[i] a i max_num -= a[i] max_num a[i] a i for i in range(max(p, 1), n - 1):
    ope.append([min_num, a[i]])
    min_num -= a[i] i range(max(p, 1), n - 1) range max(p, 1) max p 1 n - 1 n 1 ope.append([min_num, a[i]]) ope.append ope append [min_num, a[i]] min_num a[i] a i min_num -= a[i] min_num a[i] a i ope.append([max_num, min_num]) ope.append ope append [max_num, min_num] max_num min_num print(max_num - min_num) print max_num - min_num max_num min_num for i in range(n - 1):
    print(" ".join(map(str, ope[i]))) i range(n - 1) range n - 1 n 1 print(" ".join(map(str, ope[i]))) print " ".join(map(str, ope[i])) " ".join " " join map(str, ope[i]) map str ope[i] ope i n = int(input()) int(input()) n min_num -= a[i] a[i] min_num p = bisect.bisect_left(a, 0) bisect.bisect_left(a, 0) p max_num -= a[i] a[i] max_num ope = [] [] ope a = list(map(int, input().split())) list(map(int, input().split())) a max_num = a[-1] a[-1] max_num min_num = a[0] a[0] min_num
import bisect
n = int(input())
a = list(map(int, input().split()))

a.sort()
ope = []
max_num = a[-1]
min_num = a[0]
p = bisect.bisect_left(a, 0)
for i in range(1, min(p, n - 1)):
    ope.append([max_num, a[i]])
    max_num -= a[i]
for i in range(max(p, 1), n - 1):
    ope.append([min_num, a[i]])
    min_num -= a[i]
ope.append([max_num, min_num])
print(max_num - min_num)
for i in range(n - 1):
    print(" ".join(map(str, ope[i])))