n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = []
for i in range(1, n-1):
    if a[i] <= 0:
        ans.append([a[n-1], a[i]])
        a[n-1] += abs(a[i])

    else:
        ans.append([a[0], a[i]])
        a[0] -= a[i]
        
ans.append([a[n-1], a[0]])

print(a[n-1] - a[0])
for i in range(n-1):
    print(*ans[i]) 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 ans = [] ans [] for i in range(1, n-1):
    if a[i] <= 0:
        ans.append([a[n-1], a[i]])
        a[n-1] += abs(a[i])

    else:
        ans.append([a[0], a[i]])
        a[0] -= a[i]
         i range(1, n-1) range 1 n-1 n 1 if a[i] <= 0:
        ans.append([a[n-1], a[i]])
        a[n-1] += abs(a[i])

    else:
        ans.append([a[0], a[i]])
        a[0] -= a[i]
         a[i] <= 0 a[i] a i 0 ans.append([a[n-1], a[i]]) ans.append ans append [a[n-1], a[i]] a[n-1] a n-1 n 1 a[i] a i a[n-1] += abs(a[i]) a[n-1] a n-1 n 1 abs(a[i]) abs a[i] a i ans.append([a[0], a[i]]) ans.append ans append [a[0], a[i]] a[0] a 0 a[i] a i a[0] -= a[i] a[0] a 0 a[i] a i ans.append([a[n-1], a[0]]) ans.append ans append [a[n-1], a[0]] a[n-1] a n-1 n 1 a[0] a 0 print(a[n-1] - a[0]) print a[n-1] - a[0] a[n-1] a n-1 n 1 a[0] a 0 for i in range(n-1):
    print(*ans[i]) i range(n-1) range n-1 n 1 print(*ans[i]) print *ans[i] ans[i] ans i n = int(input()) int(input()) n ans = [] [] ans a = list(map(int, input().split())) list(map(int, input().split())) a
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = []
for i in range(1, n-1):
    if a[i] <= 0:
        ans.append([a[n-1], a[i]])
        a[n-1] += abs(a[i])

    else:
        ans.append([a[0], a[i]])
        a[0] -= a[i]
        
ans.append([a[n-1], a[0]])

print(a[n-1] - a[0])
for i in range(n-1):
    print(*ans[i])
