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

A.sort()
from collections import deque
d = deque(A)
ans = []
r = d.pop()
for i in range(N-1):
  l = d.popleft()
  if i < N-2:
    nex = d.pop()
  else:
    nex = -1
  if nex>=0:
    ans.append((min(l,r),max(l,r)))
    d.appendleft((-1)*abs(l-r))
  else:
    ans.append((max(l,r),min(l,r)))
    d.appendleft(abs(l-r))
  r = nex
print(d.pop())
for a in ans:
  print(*a,sep=' ') 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 from collections import deque d = deque(A) d deque(A) deque A ans = [] ans [] r = d.pop() r d.pop() d.pop d pop for i in range(N-1):
  l = d.popleft()
  if i < N-2:
    nex = d.pop()
  else:
    nex = -1
  if nex>=0:
    ans.append((min(l,r),max(l,r)))
    d.appendleft((-1)*abs(l-r))
  else:
    ans.append((max(l,r),min(l,r)))
    d.appendleft(abs(l-r))
  r = nex i range(N-1) range N-1 N 1 l = d.popleft() l d.popleft() d.popleft d popleft if i < N-2:
    nex = d.pop()
  else:
    nex = -1
   i < N-2 i N-2 N 2 nex = d.pop() nex d.pop() d.pop d pop nex = -1 nex -1 if nex>=0:
    ans.append((min(l,r),max(l,r)))
    d.appendleft((-1)*abs(l-r))
  else:
    ans.append((max(l,r),min(l,r)))
    d.appendleft(abs(l-r))
   nex>=0 nex 0 ans.append((min(l,r),max(l,r))) ans.append ans append (min(l,r),max(l,r)) min(l,r) min l r max(l,r) max l r d.appendleft((-1)*abs(l-r)) d.appendleft d appendleft (-1)*abs(l-r) -1 abs(l-r) abs l-r l r ans.append((max(l,r),min(l,r))) ans.append ans append (max(l,r),min(l,r)) max(l,r) max l r min(l,r) min l r d.appendleft(abs(l-r)) d.appendleft d appendleft abs(l-r) abs l-r l r r = nex r nex print(d.pop()) print d.pop() d.pop d pop for a in ans:
  print(*a,sep=' ') a ans print(*a,sep=' ') print *a a sep=' ' sep ' ' nex = d.pop() d.pop() nex N = int(input()) int(input()) N r = d.pop() d.pop() r r = nex nex r ans = [] [] ans A = list(map(int, input().split())) list(map(int, input().split())) A d = deque(A) deque(A) d l = d.popleft() d.popleft() l nex = -1 -1 nex
N = int(input())
A = list(map(int, input().split()))

A.sort()
from collections import deque
d = deque(A)
ans = []
r = d.pop()
for i in range(N-1):
  l = d.popleft()
  if i < N-2:
    nex = d.pop()
  else:
    nex = -1
  if nex>=0:
    ans.append((min(l,r),max(l,r)))
    d.appendleft((-1)*abs(l-r))
  else:
    ans.append((max(l,r),min(l,r)))
    d.appendleft(abs(l-r))
  r = nex
print(d.pop())
for a in ans:
  print(*a,sep=' ')