import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    min_n = min(a)
    max_n = max(a)
    minflg = True
    maxflg = True

    d = []
    for ai in a:
        if ai == min_n and minflg:
            minflg = False
            continue
        if ai == max_n and maxflg:
            maxflg = False
            continue
        d.append(ai)

    ans = []
    for ai in d:
        if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
    ans.append([max_n, min_n])

    print(max_n - min_n)

    for a, b in ans:
        print(a, b)


if __name__ == '__main__':
    main() import sys sys import re re import math math import collections collections import bisect bisect import itertools itertools import fractions fractions import functools functools import copy copy import heapq heapq import decimal decimal import statistics statistics import queue queue sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 10 ** 16 INF 10 ** 16 10 16 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 ni = lambda: int(sys.stdin.readline()) ni lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline ns = lambda: map(int, sys.stdin.readline().split()) ns lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split na = lambda: list(map(int, sys.stdin.readline().split())) na lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) nb lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) list map(lambda x: int(x) - 1, sys.stdin.readline().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def main():
    n = ni()
    a = na()

    min_n = min(a)
    max_n = max(a)
    minflg = True
    maxflg = True

    d = []
    for ai in a:
        if ai == min_n and minflg:
            minflg = False
            continue
        if ai == max_n and maxflg:
            maxflg = False
            continue
        d.append(ai)

    ans = []
    for ai in d:
        if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
    ans.append([max_n, min_n])

    print(max_n - min_n)

    for a, b in ans:
        print(a, b) main n = ni() n ni() ni a = na() a na() na min_n = min(a) min_n min(a) min a max_n = max(a) max_n max(a) max a minflg = True minflg True maxflg = True maxflg True d = [] d [] for ai in a:
        if ai == min_n and minflg:
            minflg = False
            continue
        if ai == max_n and maxflg:
            maxflg = False
            continue
        d.append(ai)

     ai a if ai == min_n and minflg:
            minflg = False
            continue
         ai == min_n and minflg ai == min_n ai min_n minflg minflg = False minflg False continue if ai == max_n and maxflg:
            maxflg = False
            continue
         ai == max_n and maxflg ai == max_n ai max_n maxflg maxflg = False maxflg False continue d.append(ai) d.append d append ai ans = [] ans [] for ai in d:
        if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
     ai d if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
     ai < 0 ai 0 ans.append([max_n, ai]) ans.append ans append [max_n, ai] max_n ai max_n -= ai max_n ai ans.append(([min_n, ai])) ans.append ans append [min_n, ai] min_n ai min_n -= ai min_n ai ans.append([max_n, min_n]) ans.append ans append [max_n, min_n] max_n min_n print(max_n - min_n) print max_n - min_n max_n min_n for a, b in ans:
        print(a, b) a b ans print(a, b) print a b if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n = ni()
    a = na()

    min_n = min(a)
    max_n = max(a)
    minflg = True
    maxflg = True

    d = []
    for ai in a:
        if ai == min_n and minflg:
            minflg = False
            continue
        if ai == max_n and maxflg:
            maxflg = False
            continue
        d.append(ai)

    ans = []
    for ai in d:
        if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
    ans.append([max_n, min_n])

    print(max_n - min_n)

    for a, b in ans:
        print(a, b) def main():
    n = ni()
    a = na()

    min_n = min(a)
    max_n = max(a)
    minflg = True
    maxflg = True

    d = []
    for ai in a:
        if ai == min_n and minflg:
            minflg = False
            continue
        if ai == max_n and maxflg:
            maxflg = False
            continue
        d.append(ai)

    ans = []
    for ai in d:
        if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
    ans.append([max_n, min_n])

    print(max_n - min_n)

    for a, b in ans:
        print(a, b) main nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split())) nb INF = 10 ** 16 10 ** 16 INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD ni = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ni na = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) na ns = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) ns
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()

    min_n = min(a)
    max_n = max(a)
    minflg = True
    maxflg = True

    d = []
    for ai in a:
        if ai == min_n and minflg:
            minflg = False
            continue
        if ai == max_n and maxflg:
            maxflg = False
            continue
        d.append(ai)

    ans = []
    for ai in d:
        if ai < 0:
            ans.append([max_n, ai])
            max_n -= ai
        else:
            ans.append(([min_n, ai]))
            min_n -= ai
    ans.append([max_n, min_n])

    print(max_n - min_n)

    for a, b in ans:
        print(a, b)


if __name__ == '__main__':
    main()
