import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))

a, b = max(A), min(A)
for t in [a, b]:
    for i in range(len(A)):
        if A[i] == t:
            A.pop(i)
            break

ans = a-b
for i in range(n-2):
    ans += abs(A[i])
print(ans)

for i in range(n-2):
    if A[i] > 0:
        print(b, A[i])
        b -= A[i]
    else:
        print(a, A[i])
        a -= A[i]
print(a, b) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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, b = max(A), min(A) a max(A) max A b min(A) min A for t in [a, b]:
    for i in range(len(A)):
        if A[i] == t:
            A.pop(i)
            break t [a, b] a b for i in range(len(A)):
        if A[i] == t:
            A.pop(i)
            break i range(len(A)) range len(A) len A if A[i] == t:
            A.pop(i)
            break A[i] == t A[i] A i t A.pop(i) A.pop A pop i break ans = a-b ans a-b a b for i in range(n-2):
    ans += abs(A[i]) i range(n-2) range n-2 n 2 ans += abs(A[i]) ans abs(A[i]) abs A[i] A i print(ans) print ans for i in range(n-2):
    if A[i] > 0:
        print(b, A[i])
        b -= A[i]
    else:
        print(a, A[i])
        a -= A[i] i range(n-2) range n-2 n 2 if A[i] > 0:
        print(b, A[i])
        b -= A[i]
    else:
        print(a, A[i])
        a -= A[i] A[i] > 0 A[i] A i 0 print(b, A[i]) print b A[i] A i b -= A[i] b A[i] A i print(a, A[i]) print a A[i] A i a -= A[i] a A[i] A i print(a, b) print a b b = max(A), min(A) min(A) b a -= A[i] A[i] a ans += abs(A[i]) abs(A[i]) ans b -= A[i] A[i] b input = sys.stdin.readline sys.stdin.readline input ans = a-b a-b ans A = list(map(int,input().split())) list(map(int,input().split())) A a, b = max(A), min(A) max(A) a n = int(input()) int(input()) n
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))

a, b = max(A), min(A)
for t in [a, b]:
    for i in range(len(A)):
        if A[i] == t:
            A.pop(i)
            break

ans = a-b
for i in range(n-2):
    ans += abs(A[i])
print(ans)

for i in range(n-2):
    if A[i] > 0:
        print(b, A[i])
        b -= A[i]
    else:
        print(a, A[i])
        a -= A[i]
print(a, b)