from itertools import accumulate

from bisect import bisect, bisect_left

from functools import reduce

from itertools import accumulate, product

from operator import itemgetter, xor, mul

from math import sqrt

from random import randint, random

from heapq import heappop, heappush



from fractions import gcd

from collections import Counter, deque, defaultdict



import sys

input = sys.stdin.readline

from sys import setrecursionlimit

setrecursionlimit(10**9)



def inpl(): return list(map(int, input().split()))

N = int(input())

A = sorted(inpl())

l = bisect_left(A, 0)

if l == 0:

    ans = []

    for i in range(N-2, 0, -1):

        ans.append("{} {}".format(str(A[0]), str(A[i])))

        A[0] -= A[i]

    ans.append("{} {}".format(str(A[-1]), str(A[0])))

    score = A[-1] - A[0]



elif l == N:

    ans = []

    for i in range(N-1):

        ans.append("{} {}".format(str(A[-1]), str(A[i])))

        A[-1] -= A[i]

    score = A[-1]



else:

    ans = []

    for i in range(l, N-1):

        ans.append("{} {}".format(str(A[0]), str(A[i])))

        A[0] -= A[i]

    for i in range(l):

        ans.append("{} {}".format(str(A[-1]), str(A[i])))

        A[-1] -= A[i]

    score = A[-1]

print(score)

print(*ans, sep="\n")

from collections import defaultdict, deque

import sys

#input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))

N = int(eval(input()))

A = sorted(inpl())

if A[-1] < 0:

    print((A[-1] - sum(A[:-1])))

    for i in range(N-2, -1, -1):

        print((A[-1], A[i]))

        A[-1] -= A[i]

else:

    print((sum(map(abs, A[1:])) - A[0]))

    for i in range(N-2, 0, -1):

        a = A[i]

        if a > 0:

            print((A[0], a))

            A[0] -= a

        else:

            print((A[-1], a))

            A[-1] -= a

    print((A[-1], A[0]))
from itertools import accumulate
from bisect import bisect, bisect_left
from functools import reduce
from itertools import accumulate, product
from operator import itemgetter, xor, mul
from math import sqrt
from random import randint, random
from heapq import heappop, heappush
from fractions import gcd
from collections import Counter, deque, defaultdict
import sys

input = sys.stdin.readline
from sys import setrecursionlimit

setrecursionlimit(10**9)


def inpl():
    return list(map(int, input().split()))


N = int(input())
A = sorted(inpl())
l = bisect_left(A, 0)
if l == 0:
    ans = []
    for i in range(N - 2, 0, -1):
        ans.append("{} {}".format(str(A[0]), str(A[i])))
        A[0] -= A[i]
    ans.append("{} {}".format(str(A[-1]), str(A[0])))
    score = A[-1] - A[0]
elif l == N:
    ans = []
    for i in range(N - 1):
        ans.append("{} {}".format(str(A[-1]), str(A[i])))
        A[-1] -= A[i]
    score = A[-1]
else:
    ans = []
    for i in range(l, N - 1):
        ans.append("{} {}".format(str(A[0]), str(A[i])))
        A[0] -= A[i]
    for i in range(l):
        ans.append("{} {}".format(str(A[-1]), str(A[i])))
        A[-1] -= A[i]
    score = A[-1]
print(score)
print(*ans, sep="\n")

from collections import defaultdict, deque
import sys

# input = sys.stdin.readline
def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
A = sorted(inpl())
if A[-1] < 0:
    print((A[-1] - sum(A[:-1])))
    for i in range(N - 2, -1, -1):
        print((A[-1], A[i]))
        A[-1] -= A[i]
else:
    print((sum(map(abs, A[1:])) - A[0]))
    for i in range(N - 2, 0, -1):
        a = A[i]
        if a > 0:
            print((A[0], a))
            A[0] -= a
        else:
            print((A[-1], a))
            A[-1] -= a
    print((A[-1], A[0]))

-from itertools import accumulate -from bisect import bisect, bisect_left -from functools import reduce -from itertools import accumulate, product -from operator import itemgetter, xor, mul -from math import sqrt -from random import randint, random -from heapq import heappop, heappush -from fractions import gcd -from collections import Counter, deque, defaultdict +from collections import defaultdict, deque -input = sys.stdin.readline -from sys import setrecursionlimit - -setrecursionlimit(10**9) - - +# input = sys.stdin.readline -N = int(input()) +N = int(eval(input())) -l = bisect_left(A, 0) -if l == 0: -    ans = [] +if A[-1] < 0: +    print((A[-1] - sum(A[:-1]))) +    for i in range(N - 2, -1, -1): +        print((A[-1], A[i])) +        A[-1] -= A[i] +else: +    print((sum(map(abs, A[1:])) - A[0])) -        ans.append("{} {}".format(str(A[0]), str(A[i]))) -        A[0] -= A[i] -    ans.append("{} {}".format(str(A[-1]), str(A[0]))) -    score = A[-1] - A[0] -elif l == N: -    ans = [] -    for i in range(N - 1): -        ans.append("{} {}".format(str(A[-1]), str(A[i]))) -        A[-1] -= A[i] -    score = A[-1] -else: -    ans = [] -    for i in range(l, N - 1): -        ans.append("{} {}".format(str(A[0]), str(A[i]))) -        A[0] -= A[i] -    for i in range(l): -        ans.append("{} {}".format(str(A[-1]), str(A[i]))) -        A[-1] -= A[i] -    score = A[-1] -print(score) -print(*ans, sep="\n") +        a = A[i] +        if a > 0: +            print((A[0], a)) +            A[0] -= a +        else: +            print((A[-1], a)) +            A[-1] -= a +    print((A[-1], A[0]))