import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
from collections import deque
l = []
r = []
for i in a:
  if i < 0:
    l.append(i)
  else:
    r.append(i)
    
ll = len(l)
rr = len(r)
r.sort()
l.sort()
ans = []
l = deque(l)
r = deque(r)

for i in range(n-1):
  if ll == 0:
    mi = r.popleft()
    ma = r.pop()
    ans.append((mi,ma))
    l.append(mi-ma)
    ll += 1
  else:
    if rr > 1:
      L = l.pop()
      R = r.pop()
      ans.append((L,R))
      l.append(L-R)
      rr -= 1
    elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
    else:
      mi = l.popleft()
      ma = l.pop()
      ans.append((ma,mi))
      r.append(ma-mi)
      rr += 1
      
p,q = ans[-1]
print(abs(p-q))
if p < q:
  ans[-1] = (q,p)
for i,j in ans:
  print(i,j) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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()] from collections import deque l = [] l [] r = [] r [] for i in a:
  if i < 0:
    l.append(i)
  else:
    r.append(i)
     i a if i < 0:
    l.append(i)
  else:
    r.append(i)
     i < 0 i 0 l.append(i) l.append l append i r.append(i) r.append r append i ll = len(l) ll len(l) len l rr = len(r) rr len(r) len r r.sort() r.sort r sort l.sort() l.sort l sort ans = [] ans [] l = deque(l) l deque(l) deque l r = deque(r) r deque(r) deque r for i in range(n-1):
  if ll == 0:
    mi = r.popleft()
    ma = r.pop()
    ans.append((mi,ma))
    l.append(mi-ma)
    ll += 1
  else:
    if rr > 1:
      L = l.pop()
      R = r.pop()
      ans.append((L,R))
      l.append(L-R)
      rr -= 1
    elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
    else:
      mi = l.popleft()
      ma = l.pop()
      ans.append((ma,mi))
      r.append(ma-mi)
      rr += 1
       i range(n-1) range n-1 n 1 if ll == 0:
    mi = r.popleft()
    ma = r.pop()
    ans.append((mi,ma))
    l.append(mi-ma)
    ll += 1
  else:
    if rr > 1:
      L = l.pop()
      R = r.pop()
      ans.append((L,R))
      l.append(L-R)
      rr -= 1
    elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
    else:
      mi = l.popleft()
      ma = l.pop()
      ans.append((ma,mi))
      r.append(ma-mi)
      rr += 1
       ll == 0 ll 0 mi = r.popleft() mi r.popleft() r.popleft r popleft ma = r.pop() ma r.pop() r.pop r pop ans.append((mi,ma)) ans.append ans append (mi,ma) mi ma l.append(mi-ma) l.append l append mi-ma mi ma ll += 1 ll 1 if rr > 1:
      L = l.pop()
      R = r.pop()
      ans.append((L,R))
      l.append(L-R)
      rr -= 1
    elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
    else:
      mi = l.popleft()
      ma = l.pop()
      ans.append((ma,mi))
      r.append(ma-mi)
      rr += 1
       rr > 1 rr 1 L = l.pop() L l.pop() l.pop l pop R = r.pop() R r.pop() r.pop r pop ans.append((L,R)) ans.append ans append (L,R) L R l.append(L-R) l.append l append L-R L R rr -= 1 rr 1 elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
     rr == 1 rr 1 L = l.pop() L l.pop() l.pop l pop R = r.pop() R r.pop() r.pop r pop ans.append((R,L)) ans.append ans append (R,L) R L r.append(R-L) r.append r append R-L R L mi = l.popleft() mi l.popleft() l.popleft l popleft ma = l.pop() ma l.pop() l.pop l pop ans.append((ma,mi)) ans.append ans append (ma,mi) ma mi r.append(ma-mi) r.append r append ma-mi ma mi rr += 1 rr 1 p,q = ans[-1] p ans[-1] ans -1 q print(abs(p-q)) print abs(p-q) abs p-q p q if p < q:
  ans[-1] = (q,p) p < q p q ans[-1] = (q,p) ans[-1] ans -1 (q,p) q p for i,j in ans:
  print(i,j) i j ans print(i,j) print i j rr = len(r) len(r) rr l = [] [] l q = ans[-1] ans[-1] q n = int(input()) int(input()) n a = [int(i) for i in input().split()] [int(i) for i in input().split()] a r = [] [] r l = deque(l) deque(l) l ma = l.pop() l.pop() ma p,q = ans[-1] ans[-1] p ma = r.pop() r.pop() ma r = deque(r) deque(r) r ans = [] [] ans ll = len(l) len(l) ll input = sys.stdin.readline sys.stdin.readline input ll += 1 1 ll rr -= 1 1 rr L = l.pop() l.pop() L mi = r.popleft() r.popleft() mi L = l.pop() l.pop() L R = r.pop() r.pop() R mi = l.popleft() l.popleft() mi R = r.pop() r.pop() R rr += 1 1 rr
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
from collections import deque
l = []
r = []
for i in a:
  if i < 0:
    l.append(i)
  else:
    r.append(i)
    
ll = len(l)
rr = len(r)
r.sort()
l.sort()
ans = []
l = deque(l)
r = deque(r)

for i in range(n-1):
  if ll == 0:
    mi = r.popleft()
    ma = r.pop()
    ans.append((mi,ma))
    l.append(mi-ma)
    ll += 1
  else:
    if rr > 1:
      L = l.pop()
      R = r.pop()
      ans.append((L,R))
      l.append(L-R)
      rr -= 1
    elif rr == 1:
      L = l.pop()
      R = r.pop()
      ans.append((R,L))
      r.append(R-L)
    else:
      mi = l.popleft()
      ma = l.pop()
      ans.append((ma,mi))
      r.append(ma-mi)
      rr += 1
      
p,q = ans[-1]
print(abs(p-q))
if p < q:
  ans[-1] = (q,p)
for i,j in ans:
  print(i,j)