from collections import deque
plusQ = deque([]) 
minsQ = deque([])
 
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
for itr, val in enumerate(A):
  if itr == 0:
    plusQ.append(val)
  elif itr != len(A) - 1 and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)
    
p1 = plusQ.popleft()
 
ans = deque([])
while len(minsQ) > 0:
  if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m

print(p1)
while len(ans) > 0:
  hoge = ans.popleft()
  print(hoge[0],hoge[1]) from collections import deque plusQ = deque([]) plusQ deque([]) deque [] minsQ = deque([]) minsQ deque([]) deque [] 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(reverse=True) A.sort A sort reverse=True reverse True for itr, val in enumerate(A):
  if itr == 0:
    plusQ.append(val)
  elif itr != len(A) - 1 and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)
     itr val enumerate(A) enumerate A if itr == 0:
    plusQ.append(val)
  elif itr != len(A) - 1 and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)
     itr == 0 itr 0 plusQ.append(val) plusQ.append plusQ append val elif itr != len(A) - 1 and val > 0:
    plusQ.append(val)
   itr != len(A) - 1 and val > 0 itr != len(A) - 1 itr len(A) - 1 len(A) len A 1 val > 0 val 0 plusQ.append(val) plusQ.append plusQ append val minsQ.append(val) minsQ.append minsQ append val p1 = plusQ.popleft() p1 plusQ.popleft() plusQ.popleft plusQ popleft ans = deque([]) ans deque([]) deque [] while len(minsQ) > 0:
  if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m len(minsQ) > 0 len(minsQ) len minsQ 0 if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m len(plusQ) > 0 len(plusQ) len plusQ 0 p, m = plusQ.popleft(), minsQ.popleft() p plusQ.popleft() plusQ.popleft plusQ popleft m minsQ.popleft() minsQ.popleft minsQ popleft ans.append([m, p]) ans.append ans append [m, p] m p minsQ.append(m - p) minsQ.append minsQ append m - p m p m = minsQ.popleft() m minsQ.popleft() minsQ.popleft minsQ popleft ans.append([p1, m]) ans.append ans append [p1, m] p1 m p1 = p1 - m p1 p1 - m p1 m print(p1) print p1 while len(ans) > 0:
  hoge = ans.popleft()
  print(hoge[0],hoge[1]) len(ans) > 0 len(ans) len ans 0 hoge = ans.popleft() hoge ans.popleft() ans.popleft ans popleft print(hoge[0],hoge[1]) print hoge[0] hoge 0 hoge[1] hoge 1 N = int(input()) int(input()) N plusQ = deque([]) deque([]) plusQ m = plusQ.popleft(), minsQ.popleft() minsQ.popleft() m A = list(map(int, input().split())) list(map(int, input().split())) A minsQ = deque([]) deque([]) minsQ m = minsQ.popleft() minsQ.popleft() m p1 = plusQ.popleft() plusQ.popleft() p1 p1 = p1 - m p1 - m p1 hoge = ans.popleft() ans.popleft() hoge p, m = plusQ.popleft(), minsQ.popleft() plusQ.popleft() p ans = deque([]) deque([]) ans
from collections import deque
plusQ = deque([]) 
minsQ = deque([])
 
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
for itr, val in enumerate(A):
  if itr == 0:
    plusQ.append(val)
  elif itr != len(A) - 1 and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)
    
p1 = plusQ.popleft()
 
ans = deque([])
while len(minsQ) > 0:
  if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m

print(p1)
while len(ans) > 0:
  hoge = ans.popleft()
  print(hoge[0],hoge[1])