from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/arc091/tasks/arc091_b
#D - Remainder Reminder
"""
if has negative

if all positive

"""

N = gi()
A = [0] * N
ans = 0
max_vi = -1
max_v = -1e4 - 1
min_vi = -1
min_v = 1e4 + 1
for i in range(N):
    a = gi()
    A[i] = a
    if (a >= max_v):
        max_vi = i
        max_v = a
    if (a < min_v):
        min_vi = i
        min_v = a
    ans += abs(a)

seq = []
for i in range(N):
    if i == max_vi or i == min_vi:
        continue
    a = A[i]
    if a >= 0:
        seq.append((min_v, a))
        min_v -= a
    else:
        seq.append((max_v, a))
        max_v -= a
print(max_v - min_v)
for p in seq:
    print("%d %d" % (p[0], p[1]))
print(max_v, min_v) from _collections import deque from _ast import Num def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number) parser while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number) 1 data = list(input().split(' ')) data list(input().split(' ')) list input().split(' ') ().split () input split ' ' for number in data:
            if len(number) > 0:
                yield (number) number data if len(number) > 0:
                yield (number) len(number) > 0 len(number) len number 0 yield (number) number input_parser = parser() input_parser parser() parser def gw():
    global input_parser
    return next(input_parser) gw global input_parser return next(input_parser) next(input_parser) next input_parser def gi():
    data = gw()
    return int(data) gi data = gw() data gw() gw return int(data) int(data) int data MOD = int(1e9 + 7) MOD int(1e9 + 7) int 1e9 + 7 1e9 7 import numpy numpy from collections import deque from math import sqrt from math import floor """
if has negative

if all positive

""" N = gi() N gi() gi A = [0] * N A [0] * N [0] 0 N ans = 0 ans 0 max_vi = -1 max_vi -1 max_v = -1e4 - 1 max_v -1e4 - 1 -1e4 1 min_vi = -1 min_vi -1 min_v = 1e4 + 1 min_v 1e4 + 1 1e4 1 for i in range(N):
    a = gi()
    A[i] = a
    if (a >= max_v):
        max_vi = i
        max_v = a
    if (a < min_v):
        min_vi = i
        min_v = a
    ans += abs(a) i range(N) range N a = gi() a gi() gi A[i] = a A[i] A i a if (a >= max_v):
        max_vi = i
        max_v = a
     a >= max_v a max_v max_vi = i max_vi i max_v = a max_v a if (a < min_v):
        min_vi = i
        min_v = a
     a < min_v a min_v min_vi = i min_vi i min_v = a min_v a ans += abs(a) ans abs(a) abs a seq = [] seq [] for i in range(N):
    if i == max_vi or i == min_vi:
        continue
    a = A[i]
    if a >= 0:
        seq.append((min_v, a))
        min_v -= a
    else:
        seq.append((max_v, a))
        max_v -= a i range(N) range N if i == max_vi or i == min_vi:
        continue
     i == max_vi or i == min_vi i == max_vi i max_vi i == min_vi i min_vi continue a = A[i] a A[i] A i if a >= 0:
        seq.append((min_v, a))
        min_v -= a
    else:
        seq.append((max_v, a))
        max_v -= a a >= 0 a 0 seq.append((min_v, a)) seq.append seq append (min_v, a) min_v a min_v -= a min_v a seq.append((max_v, a)) seq.append seq append (max_v, a) max_v a max_v -= a max_v a print(max_v - min_v) print max_v - min_v max_v min_v for p in seq:
    print("%d %d" % (p[0], p[1])) p seq print("%d %d" % (p[0], p[1])) print "%d %d" % (p[0], p[1]) "%d %d" (p[0], p[1]) p[0] p 0 p[1] p 1 print(max_v, min_v) print max_v min_v max_vi = i i max_vi seq = [] [] seq def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number) def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number) parser N = gi() gi() N max_v = -1e4 - 1 -1e4 - 1 max_v a = gi() gi() a ans = 0 0 ans input_parser = parser() parser() input_parser max_v -= a a max_v min_v = 1e4 + 1 1e4 + 1 min_v max_v = a a max_v def gi():
    data = gw()
    return int(data) def gi():
    data = gw()
    return int(data) gi MOD = int(1e9 + 7) int(1e9 + 7) MOD a = A[i] A[i] a min_v -= a a min_v min_v = a a min_v min_vi = -1 -1 min_vi A = [0] * N [0] * N A max_vi = -1 -1 max_vi min_vi = i i min_vi def gw():
    global input_parser
    return next(input_parser) def gw():
    global input_parser
    return next(input_parser) gw ans += abs(a) abs(a) ans
from _collections import deque
from _ast import Num


def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

import numpy
from collections import deque
from math import sqrt
from math import floor
#https://atcoder.jp/contests/arc091/tasks/arc091_b
#D - Remainder Reminder
"""
if has negative

if all positive

"""

N = gi()
A = [0] * N
ans = 0
max_vi = -1
max_v = -1e4 - 1
min_vi = -1
min_v = 1e4 + 1
for i in range(N):
    a = gi()
    A[i] = a
    if (a >= max_v):
        max_vi = i
        max_v = a
    if (a < min_v):
        min_vi = i
        min_v = a
    ans += abs(a)

seq = []
for i in range(N):
    if i == max_vi or i == min_vi:
        continue
    a = A[i]
    if a >= 0:
        seq.append((min_v, a))
        min_v -= a
    else:
        seq.append((max_v, a))
        max_v -= a
print(max_v - min_v)
for p in seq:
    print("%d %d" % (p[0], p[1]))
print(max_v, min_v)
