from collections import deque
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A = deque(A)
m = A.popleft()
ans = []
while len(A)>1:
  if A[-2]<=0:
    break
  x = A.pop()
  ans += [(m,x)]
  m = m-x
for i in range(len(A)-1):
  ans += [(A[-1],A[i])]
  A[-1] = A[-1]-A[i]

ans += [(A[-1],m)]
print(A[-1]-m)
for a in ans:
  print(*a) from collections import deque N = int(input()) N int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A = [int(i) for i in input().split()] A [int(i) for i in input().split()] A.sort() A.sort A sort A = deque(A) A deque(A) deque A m = A.popleft() m A.popleft() A.popleft A popleft ans = [] ans [] while len(A)>1:
  if A[-2]<=0:
    break
  x = A.pop()
  ans += [(m,x)]
  m = m-x len(A)>1 len(A) len A 1 if A[-2]<=0:
    break
   A[-2]<=0 A[-2] A -2 0 break x = A.pop() x A.pop() A.pop A pop ans += [(m,x)] ans [(m,x)] (m,x) m x m = m-x m m-x m x for i in range(len(A)-1):
  ans += [(A[-1],A[i])]
  A[-1] = A[-1]-A[i] i range(len(A)-1) range len(A)-1 len(A) len A 1 ans += [(A[-1],A[i])] ans [(A[-1],A[i])] (A[-1],A[i]) A[-1] A -1 A[i] A i A[-1] = A[-1]-A[i] A[-1] A -1 A[-1]-A[i] A[-1] A -1 A[i] A i ans += [(A[-1],m)] ans [(A[-1],m)] (A[-1],m) A[-1] A -1 m print(A[-1]-m) print A[-1]-m A[-1] A -1 m for a in ans:
  print(*a) a ans print(*a) print *a a N = int(input()) int(input()) N m = m-x m-x m A = [int(i) for i in input().split()] [int(i) for i in input().split()] A ans += [(m,x)] [(m,x)] ans ans = [] [] ans A = deque(A) deque(A) A m = A.popleft() A.popleft() m x = A.pop() A.pop() x ans += [(A[-1],A[i])] [(A[-1],A[i])] ans ans += [(A[-1],m)] [(A[-1],m)] ans
from collections import deque
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A = deque(A)
m = A.popleft()
ans = []
while len(A)>1:
  if A[-2]<=0:
    break
  x = A.pop()
  ans += [(m,x)]
  m = m-x
for i in range(len(A)-1):
  ans += [(A[-1],A[i])]
  A[-1] = A[-1]-A[i]

ans += [(A[-1],m)]
print(A[-1]-m)
for a in ans:
  print(*a)