from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(A[-1] + sum(map(abs, A[1:-1])) - A[0])
for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
  else:
    print(A[-1], a)
    A[-1] -= a
print(A[-1], A[0]) from collections import defaultdict, deque import sys sys def inpl(): return list(map(int, input().split())) inpl N = int(input()) N int(input()) int input() input A = sorted(inpl()) A sorted(inpl()) sorted inpl() inpl print(A[-1] + sum(map(abs, A[1:-1])) - A[0]) print A[-1] + sum(map(abs, A[1:-1])) - A[0] A[-1] + sum(map(abs, A[1:-1])) A[-1] A -1 sum(map(abs, A[1:-1])) sum map(abs, A[1:-1]) map abs A[1:-1] A 1:-1 1 -1 A[0] A 0 for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
  else:
    print(A[-1], a)
    A[-1] -= a i range(N-2, 0, -1) range N-2 N 2 0 -1 a = A[i] a A[i] A i if a > 0:
    print(A[0], a)
    A[0] -= a
  else:
    print(A[-1], a)
    A[-1] -= a a > 0 a 0 print(A[0], a) print A[0] A 0 a A[0] -= a A[0] A 0 a print(A[-1], a) print A[-1] A -1 a A[-1] -= a A[-1] A -1 a print(A[-1], A[0]) print A[-1] A -1 A[0] A 0 a = A[i] A[i] a A = sorted(inpl()) sorted(inpl()) A def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl N = int(input()) int(input()) N
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(A[-1] + sum(map(abs, A[1:-1])) - A[0])
for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
  else:
    print(A[-1], a)
    A[-1] -= a
print(A[-1], A[0])
