import sys, math, collections, heapq, itertools

from bisect import bisect_left

  

def solve():

    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())

    INF = 10 ** 25

    mod = 7 + 10 ** 9

    N = int(file())

    A = [int(a) for a in file().split()]

    A.sort()

    ans = 0

    out = []

    if N == 2:

        ans = A[1] - A[0]

        out = [[A[1], A[0]]]

    else:

        plus = bisect_left(A, 0)

        if plus == 0:

            ans = A[0]

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

                out.append([ans, A[i]])

                ans -= A[i]

            out.append([A[N-1], ans])

            ans = A[N-1] - ans

        elif plus < N:

            ans = A[0]

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

                out.append([ans, A[i]])

                ans -= A[i]

            out.append([A[N-1], ans])

            ans = A[N-1] - ans

            for i in range(1, plus):

                out.append([ans, A[i]])

                ans -= A[i]

        else:

            ans = A[N-1]

            for i in range(N-1):

                out.append([ans, A[i]])

                ans -= A[i]



    print(ans)

    for k in out:

        print((" ".join(map(str, k))))





    return 0

  

if __name__ == "__main__":

    solve()
import sys





def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    A = [int(a) for a in input().split()]

    A.sort()

    DP = [[None, None] for _ in range(N)]

    DP[0][0] = -A[0]

    DP[0][1] = -10 ** 20

    for i in range(1, N):

        DP[i][0] = DP[i-1][0] - A[i]

        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])

    print((DP[N-1][1]))

    flip = N

    for i in reversed(list(range(1, N))):

        if DP[i][1] - DP[i-1][1] != A[i]:

            flip = i

            break

    else: flip = 1

    sumA = A[0]

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

        print((sumA, A[i]))

        sumA -= A[i]

    print((A[N-1], sumA))

    sumA = A[N-1] - sumA

    for i in range(1, flip):

        print((sumA, A[i]))

        sumA -= A[i]



    return 0



if __name__ == "__main__":

    solve()
import sys, math, collections, heapq, itertools
from bisect import bisect_left


def solve():
    file = sys.stdin.readline  # single: int(file()), line: map(int, file().split())
    INF = 10**25
    mod = 7 + 10**9
    N = int(file())
    A = [int(a) for a in file().split()]
    A.sort()
    ans = 0
    out = []
    if N == 2:
        ans = A[1] - A[0]
        out = [[A[1], A[0]]]
    else:
        plus = bisect_left(A, 0)
        if plus == 0:
            ans = A[0]
            for i in range(1, N - 1):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[N - 1], ans])
            ans = A[N - 1] - ans
        elif plus < N:
            ans = A[0]
            for i in range(plus, N - 1):
                out.append([ans, A[i]])
                ans -= A[i]
            out.append([A[N - 1], ans])
            ans = A[N - 1] - ans
            for i in range(1, plus):
                out.append([ans, A[i]])
                ans -= A[i]
        else:
            ans = A[N - 1]
            for i in range(N - 1):
                out.append([ans, A[i]])
                ans -= A[i]
    print(ans)
    for k in out:
        print((" ".join(map(str, k))))
    return 0


if __name__ == "__main__":
    solve()

import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -(10**20)
    for i in range(1, N):
        DP[i][0] = DP[i - 1][0] - A[i]
        DP[i][1] = max(DP[i - 1][1] + A[i], DP[i - 1][0] + A[i])
    print((DP[N - 1][1]))
    flip = N
    for i in reversed(list(range(1, N))):
        if DP[i][1] - DP[i - 1][1] != A[i]:
            flip = i
            break
    else:
        flip = 1
    sumA = A[0]
    for i in range(flip, N - 1):
        print((sumA, A[i]))
        sumA -= A[i]
    print((A[N - 1], sumA))
    sumA = A[N - 1] - sumA
    for i in range(1, flip):
        print((sumA, A[i]))
        sumA -= A[i]
    return 0


if __name__ == "__main__":
    solve()

-import sys, math, collections, heapq, itertools -from bisect import bisect_left +import sys -    file = sys.stdin.readline  # single: int(file()), line: map(int, file().split()) -    INF = 10**25 -    mod = 7 + 10**9 -    N = int(file()) -    A = [int(a) for a in file().split()] +    input = sys.stdin.readline +    N = int(eval(input())) +    A = [int(a) for a in input().split()] -    ans = 0 -    out = [] -    if N == 2: -        ans = A[1] - A[0] -        out = [[A[1], A[0]]] +    DP = [[None, None] for _ in range(N)] +    DP[0][0] = -A[0] +    DP[0][1] = -(10**20) +    for i in range(1, N): +        DP[i][0] = DP[i - 1][0] - A[i] +        DP[i][1] = max(DP[i - 1][1] + A[i], DP[i - 1][0] + A[i]) +    print((DP[N - 1][1])) +    flip = N +    for i in reversed(list(range(1, N))): +        if DP[i][1] - DP[i - 1][1] != A[i]: +            flip = i +            break -        plus = bisect_left(A, 0) -        if plus == 0: -            ans = A[0] -            for i in range(1, N - 1): -                out.append([ans, A[i]]) -                ans -= A[i] -            out.append([A[N - 1], ans]) -            ans = A[N - 1] - ans -        elif plus < N: -            ans = A[0] -            for i in range(plus, N - 1): -                out.append([ans, A[i]]) -                ans -= A[i] -            out.append([A[N - 1], ans]) -            ans = A[N - 1] - ans -            for i in range(1, plus): -                out.append([ans, A[i]]) -                ans -= A[i] -        else: -            ans = A[N - 1] -            for i in range(N - 1): -                out.append([ans, A[i]]) -                ans -= A[i] -    print(ans) -    for k in out: -        print((" ".join(map(str, k)))) +        flip = 1 +    sumA = A[0] +    for i in range(flip, N - 1): +        print((sumA, A[i])) +        sumA -= A[i] +    print((A[N - 1], sumA)) +    sumA = A[N - 1] - sumA +    for i in range(1, flip): +        print((sumA, A[i])) +        sumA -= A[i]