import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    A.sort()
    a0 = A[0]
    a3 = A[N-1]
    A12 = A[1:N-1]
    iz = bisect_left(A12, 0)
    A1 = A12[:iz]
    A2 = A12[iz:]

    logs = []
    def logging(x, y):
        logs.append('%d %d' % (x, y))
        return x - y
    x = a0
    for y in A2:
        x = logging(x, y)
    y = x
    x = a3
    x = logging(x, y)
    for y in A1:
        x = logging(x, y)
    print(x)
    for log in logs:
        print(log)

main() import sys sys from collections import deque from collections import defaultdict from heapq import heapify, heappush, heappop, heappushpop from bisect import bisect_left, bisect_right int(c) for c in s.split(' ') for c in s.split(' ') c s.split(' ') s.split s split ' ' for c in s.split(' ') int(c) int c s2nn = lambda s: [int(c) for c in s.split(' ')] s2nn lambda s: [int(c) for c in s.split(' ')] [int(c) for c in s.split(' ')] s int(s) for s in ss for s in ss s ss for s in ss int(s) int s ss2nn = lambda ss: [int(s) for s in ss] ss2nn lambda ss: [int(s) for s in ss] [int(s) for s in ss] ss s2nn(s) for s in ss for s in ss s ss for s in ss s2nn(s) s2nn s ss2nnn = lambda ss: [s2nn(s) for s in ss] ss2nnn lambda ss: [s2nn(s) for s in ss] [s2nn(s) for s in ss] ss i2s = lambda: sys.stdin.readline().rstrip() i2s lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip i2n = lambda: int(i2s()) i2n lambda: int(i2s()) int(i2s()) int i2s() i2s i2nn = lambda: s2nn(i2s()) i2nn lambda: s2nn(i2s()) s2nn(i2s()) s2nn i2s() i2s sys.stdin.readline().rstrip() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2ss lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] [sys.stdin.readline().rstrip() for _ in range(n)] n ii2nn = lambda n: ss2nn(ii2ss(n)) ii2nn lambda n: ss2nn(ii2ss(n)) ss2nn(ii2ss(n)) ss2nn ii2ss(n) ii2ss n n ii2nnn = lambda n: ss2nnn(ii2ss(n)) ii2nnn lambda n: ss2nnn(ii2ss(n)) ss2nnn(ii2ss(n)) ss2nnn ii2ss(n) ii2ss n n def main():
    N = i2n()
    A = i2nn()
    A.sort()
    a0 = A[0]
    a3 = A[N-1]
    A12 = A[1:N-1]
    iz = bisect_left(A12, 0)
    A1 = A12[:iz]
    A2 = A12[iz:]

    logs = []
    def logging(x, y):
        logs.append('%d %d' % (x, y))
        return x - y
    x = a0
    for y in A2:
        x = logging(x, y)
    y = x
    x = a3
    x = logging(x, y)
    for y in A1:
        x = logging(x, y)
    print(x)
    for log in logs:
        print(log) main N = i2n() N i2n() i2n A = i2nn() A i2nn() i2nn A.sort() A.sort A sort a0 = A[0] a0 A[0] A 0 a3 = A[N-1] a3 A[N-1] A N-1 N 1 A12 = A[1:N-1] A12 A[1:N-1] A 1:N-1 1 N-1 N 1 iz = bisect_left(A12, 0) iz bisect_left(A12, 0) bisect_left A12 0 A1 = A12[:iz] A1 A12[:iz] A12 :iz iz A2 = A12[iz:] A2 A12[iz:] A12 iz: iz logs = [] logs [] def logging(x, y):
        logs.append('%d %d' % (x, y))
        return x - y
     logging logs.append('%d %d' % (x, y)) logs.append logs append '%d %d' % (x, y) '%d %d' (x, y) x y return x - y x - y x y x x y y x = a0 x a0 for y in A2:
        x = logging(x, y)
     y A2 x = logging(x, y) x logging(x, y) logging x y y = x y x x = a3 x a3 x = logging(x, y) x logging(x, y) logging x y for y in A1:
        x = logging(x, y)
     y A1 x = logging(x, y) x logging(x, y) logging x y print(x) print x for log in logs:
        print(log) log logs print(log) print log main() main def main():
    N = i2n()
    A = i2nn()
    A.sort()
    a0 = A[0]
    a3 = A[N-1]
    A12 = A[1:N-1]
    iz = bisect_left(A12, 0)
    A1 = A12[:iz]
    A2 = A12[iz:]

    logs = []
    def logging(x, y):
        logs.append('%d %d' % (x, y))
        return x - y
    x = a0
    for y in A2:
        x = logging(x, y)
    y = x
    x = a3
    x = logging(x, y)
    for y in A1:
        x = logging(x, y)
    print(x)
    for log in logs:
        print(log) def main():
    N = i2n()
    A = i2nn()
    A.sort()
    a0 = A[0]
    a3 = A[N-1]
    A12 = A[1:N-1]
    iz = bisect_left(A12, 0)
    A1 = A12[:iz]
    A2 = A12[iz:]

    logs = []
    def logging(x, y):
        logs.append('%d %d' % (x, y))
        return x - y
    x = a0
    for y in A2:
        x = logging(x, y)
    y = x
    x = a3
    x = logging(x, y)
    for y in A1:
        x = logging(x, y)
    print(x)
    for log in logs:
        print(log) main i2n = lambda: int(i2s()) lambda: int(i2s()) i2n s2nn = lambda s: [int(c) for c in s.split(' ')] lambda s: [int(c) for c in s.split(' ')] s2nn ii2nnn = lambda n: ss2nnn(ii2ss(n)) lambda n: ss2nnn(ii2ss(n)) ii2nnn ss2nnn = lambda ss: [s2nn(s) for s in ss] lambda ss: [s2nn(s) for s in ss] ss2nnn ii2nn = lambda n: ss2nn(ii2ss(n)) lambda n: ss2nn(ii2ss(n)) ii2nn ss2nn = lambda ss: [int(s) for s in ss] lambda ss: [int(s) for s in ss] ss2nn i2s = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() i2s i2nn = lambda: s2nn(i2s()) lambda: s2nn(i2s()) i2nn ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] lambda n: [sys.stdin.readline().rstrip() for _ in range(n)] ii2ss
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    A.sort()
    a0 = A[0]
    a3 = A[N-1]
    A12 = A[1:N-1]
    iz = bisect_left(A12, 0)
    A1 = A12[:iz]
    A2 = A12[iz:]

    logs = []
    def logging(x, y):
        logs.append('%d %d' % (x, y))
        return x - y
    x = a0
    for y in A2:
        x = logging(x, y)
    y = x
    x = a3
    x = logging(x, y)
    for y in A1:
        x = logging(x, y)
    print(x)
    for log in logs:
        print(log)

main()
