# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_c

# 重要な性質: Aの各要素には好きな符号をつけるように構成できる。ただしすべて+or-はむり
# つまり負数なら-をつけ、正数ならそのまま

# 正にすべてプラスを付ける方法→負数を一つ借りて、正を引いてひって、最後に符号を逆転
# 負数に-を付ける方法→ただ引くだけで良い


# すべて負or正のときに注意して実装
N = int(input())
A = list(map(int, input().split()))

A.sort()


if A[0] >= 0:  # もし全要素が正数なら
    now = A[0]
    ansls = []
    for a in A[1:-1]:
        ansls.append((now, a))
        now = now - a

    ansls.append((A[-1], now))
    ans = A[-1] - now
    print(ans)
    for ans in ansls:
        print(*ans)
elif A[-1] <= 0:  # もし全要素が負数なら
    A = A[::-1]
    now = A[0]
    ansls = []
    for a in A[1:]:
        ansls.append((now, a))
        now = now - a

    print(now)
    for ans in ansls:
        print(*ans)
else:  # 正負が混在するならば好きに作れる
    ans = sum([abs(a) for a in A])
    print(ans)
    from bisect import bisect_right
    idx = bisect_right(A, 0) - 1  # ギリ負数を指す

    now = A[idx]
    ansls = []
    # 正の最善戦略
    for a in A[idx + 1:-1]:
        ansls.append((now, a))
        now = now - a
    ansls.append((A[-1], now))
    now = A[-1] - now  # ためていた符号大反転

    # print('-')
    # 続いて負の最善戦略
    for a in A[:idx]:
        ansls.append((now, a))
        now = now - a
    assert now == ans

    for ans in ansls:
        print(*ans) N = int(input()) N int(input()) int input() input A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split A.sort() A.sort A sort if A[0] >= 0:  # もし全要素が正数なら
    now = A[0]
    ansls = []
    for a in A[1:-1]:
        ansls.append((now, a))
        now = now - a

    ansls.append((A[-1], now))
    ans = A[-1] - now
    print(ans)
    for ans in ansls:
        print(*ans)
elif A[-1] <= 0:  # もし全要素が負数なら
    A = A[::-1]
    now = A[0]
    ansls = []
    for a in A[1:]:
        ansls.append((now, a))
        now = now - a

    print(now)
    for ans in ansls:
        print(*ans)
else:  # 正負が混在するならば好きに作れる
    ans = sum([abs(a) for a in A])
    print(ans)
    from bisect import bisect_right
    idx = bisect_right(A, 0) - 1  # ギリ負数を指す

    now = A[idx]
    ansls = []
    # 正の最善戦略
    for a in A[idx + 1:-1]:
        ansls.append((now, a))
        now = now - a
    ansls.append((A[-1], now))
    now = A[-1] - now  # ためていた符号大反転

    # print('-')
    # 続いて負の最善戦略
    for a in A[:idx]:
        ansls.append((now, a))
        now = now - a
    assert now == ans

    for ans in ansls:
        print(*ans) A[0] >= 0 A[0] A 0 0 now = A[0] now A[0] A 0 ansls = [] ansls [] for a in A[1:-1]:
        ansls.append((now, a))
        now = now - a

     a A[1:-1] A 1:-1 1 -1 ansls.append((now, a)) ansls.append ansls append (now, a) now a now = now - a now now - a now a ansls.append((A[-1], now)) ansls.append ansls append (A[-1], now) A[-1] A -1 now ans = A[-1] - now ans A[-1] - now A[-1] A -1 now print(ans) print ans for ans in ansls:
        print(*ans) ans ansls print(*ans) print *ans ans elif A[-1] <= 0:  # もし全要素が負数なら
    A = A[::-1]
    now = A[0]
    ansls = []
    for a in A[1:]:
        ansls.append((now, a))
        now = now - a

    print(now)
    for ans in ansls:
        print(*ans) A[-1] <= 0 A[-1] A -1 0 A = A[::-1] A A[::-1] A ::-1 -1 now = A[0] now A[0] A 0 ansls = [] ansls [] for a in A[1:]:
        ansls.append((now, a))
        now = now - a

     a A[1:] A 1: 1 ansls.append((now, a)) ansls.append ansls append (now, a) now a now = now - a now now - a now a print(now) print now for ans in ansls:
        print(*ans) ans ansls print(*ans) print *ans ans abs(a) for a in A for a in A a A for a in A abs(a) abs a ans = sum([abs(a) for a in A]) ans sum([abs(a) for a in A]) sum [abs(a) for a in A] print(ans) print ans from bisect import bisect_right idx = bisect_right(A, 0) - 1 idx bisect_right(A, 0) - 1 bisect_right(A, 0) bisect_right A 0 1 now = A[idx] now A[idx] A idx ansls = [] ansls [] for a in A[idx + 1:-1]:
        ansls.append((now, a))
        now = now - a
     a A[idx + 1:-1] A idx + 1:-1 idx + 1 idx 1 -1 ansls.append((now, a)) ansls.append ansls append (now, a) now a now = now - a now now - a now a ansls.append((A[-1], now)) ansls.append ansls append (A[-1], now) A[-1] A -1 now now = A[-1] - now now A[-1] - now A[-1] A -1 now for a in A[:idx]:
        ansls.append((now, a))
        now = now - a
     a A[:idx] A :idx idx ansls.append((now, a)) ansls.append ansls append (now, a) now a now = now - a now now - a now a assert now == ans now == ans now ans for ans in ansls:
        print(*ans) ans ansls print(*ans) print *ans ans now = now - a now - a now ansls = [] [] ansls now = now - a now - a now now = now - a now - a now N = int(input()) int(input()) N A = list(map(int, input().split())) list(map(int, input().split())) A ans = sum([abs(a) for a in A]) sum([abs(a) for a in A]) ans now = A[idx] A[idx] now ans = A[-1] - now A[-1] - now ans A = A[::-1] A[::-1] A now = A[-1] - now A[-1] - now now now = now - a now - a now now = A[0] A[0] now ansls = [] [] ansls ansls = [] [] ansls idx = bisect_right(A, 0) - 1 bisect_right(A, 0) - 1 idx now = A[0] A[0] now
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_c

# 重要な性質: Aの各要素には好きな符号をつけるように構成できる。ただしすべて+or-はむり
# つまり負数なら-をつけ、正数ならそのまま

# 正にすべてプラスを付ける方法→負数を一つ借りて、正を引いてひって、最後に符号を逆転
# 負数に-を付ける方法→ただ引くだけで良い


# すべて負or正のときに注意して実装
N = int(input())
A = list(map(int, input().split()))

A.sort()


if A[0] >= 0:  # もし全要素が正数なら
    now = A[0]
    ansls = []
    for a in A[1:-1]:
        ansls.append((now, a))
        now = now - a

    ansls.append((A[-1], now))
    ans = A[-1] - now
    print(ans)
    for ans in ansls:
        print(*ans)
elif A[-1] <= 0:  # もし全要素が負数なら
    A = A[::-1]
    now = A[0]
    ansls = []
    for a in A[1:]:
        ansls.append((now, a))
        now = now - a

    print(now)
    for ans in ansls:
        print(*ans)
else:  # 正負が混在するならば好きに作れる
    ans = sum([abs(a) for a in A])
    print(ans)
    from bisect import bisect_right
    idx = bisect_right(A, 0) - 1  # ギリ負数を指す

    now = A[idx]
    ansls = []
    # 正の最善戦略
    for a in A[idx + 1:-1]:
        ansls.append((now, a))
        now = now - a
    ansls.append((A[-1], now))
    now = A[-1] - now  # ためていた符号大反転

    # print('-')
    # 続いて負の最善戦略
    for a in A[:idx]:
        ansls.append((now, a))
        now = now - a
    assert now == ans

    for ans in ansls:
        print(*ans)
