N = int(input())
A = list(map(int, input().split()))

positive = 0
negative = 0

for a in A:
    if a > 0:
        positive += a
    else:
        negative += a

if positive == 0:  # 全部負
    # 一番大きい数から残りをすべて引く
    A.sort(reverse=True)
    now = A[0]
    ans = []
    for a in A[1:]:
        ans.append((now, a))
        now -= a
    print(now)
    for a in ans:
        print(*a)
elif negative == 0:  # 全部非負
    # 一番小さい数から引いて，最後に大きい数から引く
    A.sort()
    now = A[0]
    ans = []
    for a in A[1: N - 1]:
        ans.append((now, a))
        now -= a
    ans.append((A[-1], now))
    now = A[-1] - now
    print(now)
    for a in ans:
        print(*a)
else:
    A.sort()
    neg = A[0]
    pos = A[-1]
    ans = []
    for a in A[1: N - 1]:
        if a > 0:
            ans.append((neg, a))
            neg -= a
        else:
            ans.append((pos, a))
            pos -= a
    ans.append((pos, neg))
    print(pos - neg)
    for a in ans:
        print(*a) 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 positive = 0 positive 0 negative = 0 negative 0 for a in A:
    if a > 0:
        positive += a
    else:
        negative += a a A if a > 0:
        positive += a
    else:
        negative += a a > 0 a 0 positive += a positive a negative += a negative a if positive == 0:  # 全部負
    # 一番大きい数から残りをすべて引く
    A.sort(reverse=True)
    now = A[0]
    ans = []
    for a in A[1:]:
        ans.append((now, a))
        now -= a
    print(now)
    for a in ans:
        print(*a)
elif negative == 0:  # 全部非負
    # 一番小さい数から引いて，最後に大きい数から引く
    A.sort()
    now = A[0]
    ans = []
    for a in A[1: N - 1]:
        ans.append((now, a))
        now -= a
    ans.append((A[-1], now))
    now = A[-1] - now
    print(now)
    for a in ans:
        print(*a)
else:
    A.sort()
    neg = A[0]
    pos = A[-1]
    ans = []
    for a in A[1: N - 1]:
        if a > 0:
            ans.append((neg, a))
            neg -= a
        else:
            ans.append((pos, a))
            pos -= a
    ans.append((pos, neg))
    print(pos - neg)
    for a in ans:
        print(*a) positive == 0 positive 0 A.sort(reverse=True) A.sort A sort reverse=True reverse True now = A[0] now A[0] A 0 ans = [] ans [] for a in A[1:]:
        ans.append((now, a))
        now -= a
     a A[1:] A 1: 1 ans.append((now, a)) ans.append ans append (now, a) now a now -= a now a print(now) print now for a in ans:
        print(*a) a ans print(*a) print *a a elif negative == 0:  # 全部非負
    # 一番小さい数から引いて，最後に大きい数から引く
    A.sort()
    now = A[0]
    ans = []
    for a in A[1: N - 1]:
        ans.append((now, a))
        now -= a
    ans.append((A[-1], now))
    now = A[-1] - now
    print(now)
    for a in ans:
        print(*a) negative == 0 negative 0 A.sort() A.sort A sort now = A[0] now A[0] A 0 ans = [] ans [] for a in A[1: N - 1]:
        ans.append((now, a))
        now -= a
     a A[1: N - 1] A 1: N - 1 1 N - 1 N 1 ans.append((now, a)) ans.append ans append (now, a) now a now -= a now a ans.append((A[-1], now)) ans.append ans append (A[-1], now) A[-1] A -1 now now = A[-1] - now now A[-1] - now A[-1] A -1 now print(now) print now for a in ans:
        print(*a) a ans print(*a) print *a a A.sort() A.sort A sort neg = A[0] neg A[0] A 0 pos = A[-1] pos A[-1] A -1 ans = [] ans [] for a in A[1: N - 1]:
        if a > 0:
            ans.append((neg, a))
            neg -= a
        else:
            ans.append((pos, a))
            pos -= a
     a A[1: N - 1] A 1: N - 1 1 N - 1 N 1 if a > 0:
            ans.append((neg, a))
            neg -= a
        else:
            ans.append((pos, a))
            pos -= a
     a > 0 a 0 ans.append((neg, a)) ans.append ans append (neg, a) neg a neg -= a neg a ans.append((pos, a)) ans.append ans append (pos, a) pos a pos -= a pos a ans.append((pos, neg)) ans.append ans append (pos, neg) pos neg print(pos - neg) print pos - neg pos neg for a in ans:
        print(*a) a ans print(*a) print *a a now = A[0] A[0] now now = A[-1] - now A[-1] - now now pos = A[-1] A[-1] pos positive += a a positive now = A[0] A[0] now pos -= a a pos negative += a a negative neg = A[0] A[0] neg ans = [] [] ans positive = 0 0 positive now -= a a now N = int(input()) int(input()) N A = list(map(int, input().split())) list(map(int, input().split())) A neg -= a a neg ans = [] [] ans now -= a a now negative = 0 0 negative ans = [] [] ans
N = int(input())
A = list(map(int, input().split()))

positive = 0
negative = 0

for a in A:
    if a > 0:
        positive += a
    else:
        negative += a

if positive == 0:  # 全部負
    # 一番大きい数から残りをすべて引く
    A.sort(reverse=True)
    now = A[0]
    ans = []
    for a in A[1:]:
        ans.append((now, a))
        now -= a
    print(now)
    for a in ans:
        print(*a)
elif negative == 0:  # 全部非負
    # 一番小さい数から引いて，最後に大きい数から引く
    A.sort()
    now = A[0]
    ans = []
    for a in A[1: N - 1]:
        ans.append((now, a))
        now -= a
    ans.append((A[-1], now))
    now = A[-1] - now
    print(now)
    for a in ans:
        print(*a)
else:
    A.sort()
    neg = A[0]
    pos = A[-1]
    ans = []
    for a in A[1: N - 1]:
        if a > 0:
            ans.append((neg, a))
            neg -= a
        else:
            ans.append((pos, a))
            pos -= a
    ans.append((pos, neg))
    print(pos - neg)
    for a in ans:
        print(*a)
