from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
A = LI()
if all([a > 0 for a in A]):
    now = min(A)
    print(sum(A) - now * 2)
    A.remove(now)
    last = A.pop()
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
    print(last, now)
elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
else:
    print(sum([abs(i) for i in A]))
    minus = []
    plus = []
    for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
    minus_now = minus.pop()
    plus_now = plus.pop()
    while plus:
        nxt = plus.pop()
        print(minus_now, nxt)
        minus_now -= nxt
    while minus:
        nxt = minus.pop()
        print(plus_now, nxt)
        plus_now -= nxt
    print(plus_now, minus_now) from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify from bisect import bisect_right, bisect_left import random random from itertools import permutations, accumulate, combinations, product import sys sys import string string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor, gamma, log from operator import mul from functools import reduce from copy import deepcopy sys.setrecursionlimit(2147483647) sys.setrecursionlimit sys setrecursionlimit 2147483647 INF = 10 ** 20 INF 10 ** 20 10 20 def LI(): return list(map(int, sys.stdin.buffer.readline().split())) LI def I(): return int(sys.stdin.buffer.readline()) I def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() LS def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') S I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)] SR n n LS() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LS() LS def LSR(n): return [LS() for i in range(n)] LSR n n list(S()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) list(S()) list S() S def SRL(n): return [list(S()) for i in range(n)] SRL n n [int(j) for j in list(S())] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [int(j) for j in list(S())] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] MSRL n n mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 n = I() n I() I A = LI() A LI() LI if all([a > 0 for a in A]):
    now = min(A)
    print(sum(A) - now * 2)
    A.remove(now)
    last = A.pop()
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
    print(last, now)
elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
else:
    print(sum([abs(i) for i in A]))
    minus = []
    plus = []
    for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
    minus_now = minus.pop()
    plus_now = plus.pop()
    while plus:
        nxt = plus.pop()
        print(minus_now, nxt)
        minus_now -= nxt
    while minus:
        nxt = minus.pop()
        print(plus_now, nxt)
        plus_now -= nxt
    print(plus_now, minus_now) all([a > 0 for a in A]) all [a > 0 for a in A] now = min(A) now min(A) min A print(sum(A) - now * 2) print sum(A) - now * 2 sum(A) sum A now * 2 now 2 A.remove(now) A.remove A remove now last = A.pop() last A.pop() A.pop A pop while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
     A nxt = A.pop() nxt A.pop() A.pop A pop print(now, nxt) print now nxt now -= nxt now nxt print(last, now) print last now elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt all([a < 0 for a in A]) all [a < 0 for a in A] now = max(A) now max(A) max A print(-sum(A) + now * 2) print -sum(A) + now * 2 -sum(A) sum(A) sum A now * 2 now 2 A.remove(now) A.remove A remove now while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt A nxt = A.pop() nxt A.pop() A.pop A pop print(now, nxt) print now nxt now -= nxt now nxt abs(i) for i in A for i in A i A for i in A abs(i) abs i print(sum([abs(i) for i in A])) print sum([abs(i) for i in A]) sum [abs(i) for i in A] minus = [] minus [] plus = [] plus [] for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
     a A if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
     a > 0 a 0 plus += [a] plus [a] a elif a < 0:
            minus += [a]
         a < 0 a 0 minus += [a] minus [a] a if not plus:
                plus += [a]
            else:
                minus += [a]
     not plus plus plus += [a] plus [a] a minus += [a] minus [a] a minus_now = minus.pop() minus_now minus.pop() minus.pop minus pop plus_now = plus.pop() plus_now plus.pop() plus.pop plus pop while plus:
        nxt = plus.pop()
        print(minus_now, nxt)
        minus_now -= nxt
     plus nxt = plus.pop() nxt plus.pop() plus.pop plus pop print(minus_now, nxt) print minus_now nxt minus_now -= nxt minus_now nxt while minus:
        nxt = minus.pop()
        print(plus_now, nxt)
        plus_now -= nxt
     minus nxt = minus.pop() nxt minus.pop() minus.pop minus pop print(plus_now, nxt) print plus_now nxt plus_now -= nxt plus_now nxt print(plus_now, minus_now) print plus_now minus_now def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) LI minus = [] [] minus minus_now -= nxt nxt minus_now nxt = plus.pop() plus.pop() nxt plus_now = plus.pop() plus.pop() plus_now def SRL(n): return [list(S()) for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] SRL now = max(A) max(A) now def LSR(n): return [LS() for i in range(n)] def LSR(n): return [LS() for i in range(n)] LSR plus_now -= nxt nxt plus_now now -= nxt nxt now nxt = minus.pop() minus.pop() nxt minus_now = minus.pop() minus.pop() minus_now def I(): return int(sys.stdin.buffer.readline()) def I(): return int(sys.stdin.buffer.readline()) I INF = 10 ** 20 10 ** 20 INF n = I() I() n def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR A = LI() LI() A nxt = A.pop() A.pop() nxt plus += [a] [a] plus minus += [a] [a] minus def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split() LS plus = [] [] plus now -= nxt nxt now def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8') S plus += [a] [a] plus mod = 10 ** 9 + 7 10 ** 9 + 7 mod now = min(A) min(A) now nxt = A.pop() A.pop() nxt def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)] MSRL last = A.pop() A.pop() last def LIR(n): return [LI() for i in range(n)] def LIR(n): return [LI() for i in range(n)] LIR def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR minus += [a] [a] minus
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
A = LI()
if all([a > 0 for a in A]):
    now = min(A)
    print(sum(A) - now * 2)
    A.remove(now)
    last = A.pop()
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
    print(last, now)
elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
else:
    print(sum([abs(i) for i in A]))
    minus = []
    plus = []
    for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
    minus_now = minus.pop()
    plus_now = plus.pop()
    while plus:
        nxt = plus.pop()
        print(minus_now, nxt)
        minus_now -= nxt
    while minus:
        nxt = minus.pop()
        print(plus_now, nxt)
        plus_now -= nxt
    print(plus_now, minus_now)
