You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 ≤ N ≤ 10^5, -10^4 ≤ A_i ≤ 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.

# Buggy version:
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(sum(map(abs, A[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])

# Fixed version:
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])

# Buggy version:
# -*- coding: utf-8 -*-
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())
if A[-1] < 0:
    print(A[-1] - sum(A[:-1]))
    for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i]
else:
    print(sum(map(abs, A)))
    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])

# Fixed version:
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())
if A[-1] < 0:
    print(A[-1] - sum(A[:-1]))
    for i in range(N-2, -1, -1):
        print(A[-1], A[i])
        A[-1] -= A[i]
else:
    print(sum(map(abs, A[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])

# Buggy version:
n,*a=map(int,open(0).read().split())
a.sort()
print(sum(abs(i)for i in a)-2*abs(a[0]))
if n==2:
    print(a[1]-1[0])
    print(a[1],a[0])
else:
    print(a[0],a[-1])
    a[0]-=a[-1]
    for i in a[1:-2]:
        print(a[0],i)
        a[0]-=i
    print(a[-2],a[0])

# Fixed version:
n,*a=map(int,open(0).read().split())
a.sort()
print(sum(abs(i)for i in a)-2*min(abs(a[-1]),abs(a[0]))*(a[0]*a[-1]>0))
for i in a[1:-1]:
    if i<0:
        print(a[-1],i)
        a[-1]-=i
    else:
        print(a[0],i)
        a[0]-=i
print(a[-1],a[0])

# Buggy version:
n = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []

x = A[0]
for i in range(1, n-1):
    ans.append((x, A[i]))
    x -= A[i]
if x<0:
   ans.append((A[-1], x))
else:
    ans.append((x, A[-1]))
print(abs(A[-1] - x))
for a in ans:
    print(*a)

# Fixed version:
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = []
for i in range(1, n-1):
    if a[i] <= 0:
        ans.append([a[n-1], a[i]])
        a[n-1] += abs(a[i])

    else:
        ans.append([a[0], a[i]])
        a[0] -= a[i]
        
ans.append([a[n-1], a[0]])

print(a[n-1] - a[0])
for i in range(n-1):
    print(*ans[i])

# Buggy version:
#diverta 2019 Programming Contest 2 -C Successive Subtraction
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort()
lst2 = []
l,r = lst1[0],lst1[-1]
for i in range(1,n-1):
    mid = lst1[i]
    if mid < 0:
        lst2.append([r,mid])
        r -= mid
    else:
        lst2.append([l,mid])
        l -= mid
lst2.append([l,r])
print(abs(r-l))
for i in lst2:
    print(*i)

# Fixed version:
#diverta 2019 Programming Contest 2 -C Successive Subtraction
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort()
lst2 = []
l,r = lst1[0],lst1[-1]
for i in range(1,n-1):
    mid = lst1[i]
    if mid < 0:
        lst2.append([r,mid])
        r -= mid
    else:
        lst2.append([l,mid])
        l -= mid
lst2.append([r,l])
print(r-l)
for i in lst2:
    print(*i)

# Buggy version:
n=int(input())
a=list(map(int,input().split()))
a.sort()
xy=[]
for i in range(n-2,0,-1):
  y=a[i]
  if y>0:
    x=a[0]
    a[0]-=y
  else:
    x=a[n-1]
    a[n-1]-=y
    xy.append((x,y))
print(a[n-1]-a[0])
xy.append((a[n-1],a[0]))
print('\n'.join([' '.join(map(str,t)) for t in xy]))

# Fixed version:
N=int(input())
A=list(map(int,input().split()))

A.sort()
xy=[]
for i in range(N-2,0,-1):
    y=A[i]
    if y>0:
        x=A[0]
        A[0]-=y
    else:
        x=A[N-1]
        A[N-1]-=y
    xy.append((x,y))

print(A[N-1]-A[0])
xy.append((A[N-1],A[0]))
print('\n'.join([' '.join(map(str,t)) for t in xy]))

# Buggy version:
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))

a, b = max(A), min(A)
for t in [a, b]:
    for i in range(len(A)):
        if A[i] == t:
            A.pop(i)

ans = a-b
for i in range(n-2):
    ans += abs(A[i])
print(ans)

for i in range(n-2):
    if A[i] > 0:
        print(b, A[i])
        b -= A[i]
    else:
        print(a, A[i])
        a -= A[i]
print(a, b)

# Fixed version:
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))

a, b = max(A), min(A)
for t in [a, b]:
    for i in range(len(A)):
        if A[i] == t:
            A.pop(i)
            break

ans = a-b
for i in range(n-2):
    ans += abs(A[i])
print(ans)

for i in range(n-2):
    if A[i] > 0:
        print(b, A[i])
        b -= A[i]
    else:
        print(a, A[i])
        a -= A[i]
print(a, b)

# Buggy version:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)

left = a.popleft()
right = a.pop()

ans = []
for i in a:
    if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i
else:
    ans.append((right, left))

for x, y in ans:
    print(x, y)


# Fixed version:
from collections import deque
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = deque(a)

left = a.popleft()
right = a.pop()

ans = []
for i in a:
    if i > 0:
        ans.append((left, i))
        left -= i
    else:
        ans.append((right, i))
        right -= i
else:
    ans.append((right, left))

print(right-left)
for x, y in ans:
    print(x, y)

# Buggy version:
#%%
n = int(input())
a = list(map(int ,input().split()))

a.sort(reverse=True)
ans = []
for i in range(n):
    if i == 0:
        tmp = a[i]
    elif 1 <= i < n - 1:
        if a[i] > 0:
            a[-1] -= a[i]
            ans.append(str(a[-1]) + ' ' +  str(a[i]))
        else:
            tmp -= a[i]
            ans.append(tmp + ' ' +  str(a[i]))
    else:
        ans.append(str(tmp) + ' ' +  str(a[-1]))
        a = tmp - a[-1]
        print(a)

for i in range(len(ans)):
    print(ans[i])


# Fixed version:
#%%
n = int(input())
a = list(map(int ,input().split()))

a.sort(reverse=True)
ans = []
for i in range(n):
    if i == 0:
        tmp = a[i]
    elif 1 <= i < n - 1:
        if a[i] > 0:
            ans.append(str(a[-1]) + ' ' +  str(a[i]))
            a[-1] -= a[i]
        else:
            ans.append(str(tmp) + ' ' +  str(a[i]))
            tmp -= a[i]
    else:
        ans.append(str(tmp) + ' ' +  str(a[-1]))
        a = tmp - a[-1]
        print(a)

for i in range(len(ans)):
    x, y = map(int, ans[i].split())
    print(x, y)

# Buggy version:
N = int(input())
a = list(map(int, input().split(' ')))
a.sort(reverse=True)

process = []
p_seed = a.pop(0)
n_seed = a.pop(-1)
for e in a:
  	if e >= 0:
    	process.append((n_seed, e))
    	n_seed -= e
  	else:
    	process.append((p_seed, e))
    	p_seed -= e
process.append((p_seed, n_seed))
m = p_seed - n_seed
print(m)
for x, y in process:
    print(str(x) + ' ' + str(y))

# Fixed version:
N = int(input())
a = list(map(int, input().split(' ')))
a.sort(reverse=True)

process = []
p_seed = a.pop(0)
n_seed = a.pop(-1)
for e in a:
    if e >= 0:
        process.append((n_seed, e))
        n_seed -= e
    else:
        process.append((p_seed, e))
        p_seed -= e
process.append((p_seed, n_seed))
m = p_seed - n_seed
print(m)
for x, y in process:
    print(str(x) + ' ' + str(y))

# Buggy version:
n = int(input())
a = input().split()
for i in range(len(a)):
    a[i]=int(a[i])
# print(a)
a.sort()
# print(a)
# #両端をとっておく
hashi1 = a[0]
hashi2 = a[-1]
a.remove(a[0])
a.remove(a[-1])
# print(a)
minus_list = []
plus_list = []
for i in range(len(a)):
    if a[i]>0:
        plus_list.append(a[i])
    else:
        minus_list.append(a[i])
# print(minus_list)
# print(plus_list)
for j in range(len(minus_list)):
    hashi2 = hashi2-minus_list[j]
for l in range(len(plus_list)):
    hashi1 = hashi1 - plus_list[l]

print(hashi2-hashi1)


# Fixed version:
n = int(input())
a = input().split()
for i in range(len(a)):
    a[i]=int(a[i])
# print(a)
a.sort()
# print(a)
# #両端をとっておく
hashi1 = a[0]
hashi2 = a[-1]
a.remove(a[0])
a.remove(a[-1])
# print(a)
minus_list = []
plus_list = []
printlist = []
for i in range(len(a)):
    if a[i]>0:
        plus_list.append(a[i])
    else:
        minus_list.append(a[i])
# print(minus_list)
# print(plus_list)
for j in range(len(minus_list)):
    printlist.append(hashi2)
    printlist.append(minus_list[j])
    hashi2 = hashi2-minus_list[j]
    
for l in range(len(plus_list)):
    printlist.append(hashi1)
    printlist.append(plus_list[l])
    hashi1 = hashi1 - plus_list[l]
    
printlist.append(hashi2)
printlist.append(hashi1)
print(hashi2-hashi1)
# print(printlist)
for n in range(0,len(printlist),2):
    print(printlist[n],printlist[n+1])

# Buggy version:
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=[]

if A[0]>0:
    num=A[0]
    for i in range(1,N-1):
        ans.append([num,A[i]])
        num-=A[i]
    ans.append([A[-1],num])
    print(A[-1]-num)
    for i in range(len(ans)):
        print(ans[i])
elif A[-1]<0:
    A.sort(reverse=True)
    num=A[0]
    for i in range(1,N):
        ans.append([num,A[i]])
        num-=A[i]
    print(num)
    for i in range(len(ans)):
        print(ans[i])
else:
    M=A[-1]
    m=A[0]
    for i in range(1,N-1):
        if A[i]<0:
            ans.append([M,A[i]])
            M-=A[i]
        else:
            ans.append([m,A[i]])
            m-=A[i]
    ans.append([M,m])
    print(M-m)
    for i in range(len(ans)):
        print(ans[i])

# Fixed version:
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=[]

if A[0]>0:
    num=A[0]
    for i in range(1,N-1):
        ans.append([num,A[i]])
        num-=A[i]
    ans.append([A[-1],num])
    print(A[-1]-num)
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])
elif A[-1]<0:
    A.sort(reverse=True)
    num=A[0]
    for i in range(1,N):
        ans.append([num,A[i]])
        num-=A[i]
    print(num)
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])
else:
    M=A[-1]
    m=A[0]
    for i in range(1,N-1):
        if A[i]<0:
            ans.append([M,A[i]])
            M-=A[i]
        else:
            ans.append([m,A[i]])
            m-=A[i]
    ans.append([M,m])
    print(M-m)
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])

# Buggy version:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
anslist = []
if a[0] >= 0:
  pass
  
elif a[-1] < 0:
  pass
  
else:
  for i in range(1,n-1):
    if a[i] < 0:
      anslist.append([a[-1], a[i]])
      a[-1] -= a[i]
    else:
      anslist.append([a[0], a[i]])
      a[0] -= a[i]
  anslist.append([a[-1], a[0]])
  ans = a[-1]-a[0]
  print(ans)
  for i in range(len(anslist)):
    print(anslist[i][0], anslist[i][1])
    
  
      

# Fixed version:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
anslist = []

for i in range(1,n-1):
  if a[i] < 0:
    anslist.append([a[-1], a[i]])
    a[-1] -= a[i]
  else:
    anslist.append([a[0], a[i]])
    a[0] -= a[i]
anslist.append([a[-1], a[0]])
ans = a[-1]-a[0]
print(ans)
for i in range(len(anslist)):
  print(anslist[i][0], anslist[i][1])

# Buggy version:
import bisect
n = int(input())
a = list(map(int, input().split()))

a.sort()
ope = []
max_num = a[-1]
min_num = a[0]
p = bisect.bisect_left(a, 0)
for i in range(1, p):
    ope.append([max_num, a[i]])
    max_num -= a[i]
for i in range(p, n - 1):
    ope.append([min_num, a[i]])
    min_num -= a[i]
ope.append([max_num, min_num])
print(max_num - min_num)
for i in range(n - 1):
    print(" ".join(map(str, ope[i])))

# Fixed version:
import bisect
n = int(input())
a = list(map(int, input().split()))

a.sort()
ope = []
max_num = a[-1]
min_num = a[0]
p = bisect.bisect_left(a, 0)
for i in range(1, min(p, n - 1)):
    ope.append([max_num, a[i]])
    max_num -= a[i]
for i in range(max(p, 1), n - 1):
    ope.append([min_num, a[i]])
    min_num -= a[i]
ope.append([max_num, min_num])
print(max_num - min_num)
for i in range(n - 1):
    print(" ".join(map(str, ope[i])))

# Buggy version:
N = int(input())
A = sorted(list(map(int,input().split())))

p = A[-1]
n = A[0]

ans_list = []

for a in A[1:-1]:
    if a >= 0:
        ans_list.append((n, a))
        n -= a
    else:
        ans_list.append((p, a))
        p -= a

M = p - n
ans_list.append((p, n))

print(M)
for ans in ans_list:
    print(ans)

# Fixed version:
N = int(input())
A = sorted(list(map(int,input().split())))

p = A[-1]
n = A[0]

ans_list = []

for a in A[1:-1]:
    if a >= 0:
        ans_list.append((n, a))
        n -= a
    else:
        ans_list.append((p, a))
        p -= a

M = p - n
ans_list.append((p, n))

print(M)
for x, y in ans_list:
    print(x, y)

# Buggy version:
N = int(input())
A = sorted(list(map(int,input().split())))

ans_list = []
p = []
n = []

# 最大にプラス、最小にマイナスを割り当てる
p.append(A[-1])
n.append(A[0])

# 正ならプラスを負ならマイナスを割り当てる
for a in A[1:-1]:
    if a >= 0:
        p.append(a)
    elif a < 0:
        n.append(a)

# プラスが１つになるまで消す
while len(p) != 1:
    x = n.pop()
    y = p.pop()
    n.append(x-y)
    ans_list.append((x, y))

# マイナスがなくなるまで消す
while len(n) != 0:
    x = p.pop()
    y = n.pop()
    p.append(x-y)
    ans_list.append((x,y))

# 残ったものが最大値
M = p[0]
print(M)
for ans in ans_list:
    print(ans)

# Fixed version:
N = int(input())
A = sorted(list(map(int,input().split())))

ans_list = []
p = []
n = []

# 最大にプラス、最小にマイナスを割り当てる
p.append(A[-1])
n.append(A[0])

# 正ならプラスを負ならマイナスを割り当てる
for a in A[1:-1]:
    if a >= 0:
        p.append(a)
    elif a < 0:
        n.append(a)

# プラスが１つになるまで消す
while len(p) != 1:
    x = n.pop()
    y = p.pop()
    n.append(x-y)
    ans_list.append((x, y))

# マイナスがなくなるまで消す
while len(n) != 0:
    x = p.pop()
    y = n.pop()
    p.append(x-y)
    ans_list.append((x,y))

# 残ったものが最大値
M = p[0]
print(M)
for x, y in ans_list:
    print(x, y)

# Buggy version:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

# すべて正
if A[-1] > 0 :
    a = A.pop()
    b = A.pop()
    print(a, b)
    A.append(a - b)
# すべて負
elif A[0] < 0 :
    a = A.pop(0)
    b = A.pop()
    print(a, b)
    A = [a-b] + A
    
i = 1
while A[i] > 0 :
    a = A.pop()
    print(a, A[i])
    A.append(a-A[i])
    i += 1
    
print(A[0], A[-1])
print(A[0]-A[-1])
    

# Fixed version:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)

log = []

# すべて正
if A[-1] > 0 :
    a = A.pop()
    b = A.pop()
    log.append([a, b])
    A.append(a - b)
# すべて負
elif A[0] < 0 :
    a = A.pop(0)
    b = A.pop()
    log.append([a, b])
    A = [a-b] + A
    
i = 1
while A[i] > 0 :
    a = A.pop()
    log.append([a, A[i]])
    A.append(a-A[i])
    i += 1
    
while i < len(A) :
    log.append([A[0], A[i]])
    A[0] -= A[i]
    i += 1
    
print(A[0])
for l in log :
    print(l[0], l[1])

# Buggy version:
N=int(input())
listA=list(map(int,input().split()))
listB=[abs(i) for i in listA]
MAX=max(listA)
MIN=min(listA)
ans=sum(listB)
if MIN<=0:
  print(ans)
else:
  print(ans-MIN)
listC=sorted(listA)  
for i in range(len(listA)-2):
  if listC[i+1]>=0:
    print(MIN,listC[i+1])
    MIN=MIN-listC[i+1]
  else:
    print(MAX,listC[i+1])
    MAX=MAX-listC[i+1]
print(MAX,MIN)

# Fixed version:
N=int(input())
listA=list(map(int,input().split()))
listB=[abs(i) for i in listA]
MAX=max(listA)
MIN=min(listA)
ans=sum(listB)
if MAX<=0:
  print(ans+MAX*2)
elif MIN<=0:
  print(ans)   
else:
  print(ans-MIN*2)
listC=sorted(listA)  
for i in range(len(listA)-2):
  if listC[i+1]>=0:
    print(MIN,listC[i+1])
    MIN=MIN-listC[i+1]
  else:
    print(MAX,listC[i+1])
    MAX=MAX-listC[i+1]
print(MAX,MIN)

# Buggy version:
n=int(input())
a=[]
r=[]
for i in input().split():
  a.append(int(i))
a.sort()
t=a[-1]
b=a[0]
for i in a[1:-1]:
  if i>=0:
    r.append([b,i])
    b=b-i
  else:
    r.append([t,i])
    t=t-i
print(t-b)
for i in r:
  print(r[0],r[1])


# Fixed version:
n=int(input())
a=[]
r=[]
for i in input().split():
  a.append(int(i))
a.sort()
t=a.pop(-1)
b=a.pop(0)
for i in a:
  if i>=0:
    r.append([b,i])
    b=b-i
  else:
    r.append([t,i])
    t=t-i
print(t-b)
r.append([t,b])
for i in r:
  print(i[0],i[1])

# Buggy version:
import sys
N = int(input())
A = sorted(list(map(int,input().split())))

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([a, mn])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1])

# Fixed version:
import sys
N = int(input())
A = sorted(list(map(int,input().split())))

mn = A[0]
mx = A[-1]
if N ==2:
    print(A[1] - A[0])
    print(A[1],A[0])
    sys.exit()
ope = []
for a in A[1:-1]:
    if a <=0:
        ope.append([mx, a])
        mx -= a
    else:
        ope.append([mn, a])
        mn -= a
ope.append([mx,mn])
print(mx-mn)
for o in ope:
    print(o[0],o[1])

# Buggy version:
N = int(input())
A = list(map(int, input().split()))

BB = A[:]

BB_P = []
BB_M = []


for b in BB:
    if b < 0:
        BB_M.append(b)
    else:
        BB_P.append(b)

        
ope = []
if not BB_M:
    BB_P = sorted(BB_P)
    p = BB_P[-1]
    m = BB_P[0]
    for b in BB_P[1:-1]:
        ope.append((m,b))
        m = m-b
    ope.append((p,m))
    ans = p - m
elif not BB_P:
    BB_M = sorted(BB_M)
    p = BB_M[-1]
    for b in BB_M[:-1]:
        ope.append((p, b))
        p = p-b
    ans = p
else:
    p = BB_P.pop()
    m = BB_M.pop()
    for b in BB_P:
        ope.append((m ,b))
        m = m-b
    for b in BB_M:
        ope.append((p ,b))
        p = p-b
    ope((p,m))
    ans = p-m
    
print(ans)
for x,y in ope:
    print(x, y)


# Fixed version:
N = int(input())
A = list(map(int, input().split()))

BB = A[:]

BB_P = []
BB_M = []


for b in BB:
    if b < 0:
        BB_M.append(b)
    else:
        BB_P.append(b)

        
ope = []
if not BB_M:
    BB_P = sorted(BB_P)
    p = BB_P[-1]
    m = BB_P[0]
    for b in BB_P[1:-1]:
        ope.append((m,b))
        m = m-b
    ope.append((p,m))
    ans = p - m
elif not BB_P:
    BB_M = sorted(BB_M)
    p = BB_M[-1]
    for b in BB_M[:-1]:
        ope.append((p, b))
        p = p-b
    ans = p
else:
    p = BB_P.pop()
    m = BB_M.pop()
    for b in BB_P:
        ope.append((m ,b))
        m = m-b
    for b in BB_M:
        ope.append((p ,b))
        p = p-b
    ope.append((p,m))
    ans = p-m
    
print(ans)
for x,y in ope:
    print(x, y)

# Buggy version:
import sys


def plus(pl):
    if len(pl) == 1:
        return pl[0]
    pl.sort()
    tmp = pl.pop(0)
    while len(pl) > 1:
        tmp2 = pl.pop(0)
        print(tmp, tmp2)
        tmp -= tmp2
    print(pl[0], tmp)
    return pl[0]-tmp


def minas(mi):
    if len(mi) == 1:
        return mi[0]
    mi.sort()
    tmp = mi.pop()
    while len(mi) > 1:
        tmp2 = mi.pop()
        print(tmp, tmp2)
        tmp -= tmp2
    print(tmp, mi[0])
    return tmp-mi[0]


n = int(input())

mi = []
pl = []

for i in [int(j) for j in input().split()]:
    if i < 0:
        mi.append(i)
    else:
        pl.append(i)

if len(pl) == 0:
    print(abs(sum(mi)-max(mi)))
    minas(mi)
elif len(mi) == 0:
    print(sum(pl)-min(pl))
    plus(pl)
else:
    print(abs(sum(mi))+sum(pl))
    mi.sort()
    pl.sort(reverse=True)
    while len(pl) > 1:
        tmp = pl.pop()
        print(mi[0], tmp)
        mi[0] -= tmp

    while len(mi) > 1:
        tmp = mi.pop()
        print(mi[0], tmp)
        mi[0] -= tmp

    print(pl[0], mi[0])


# Fixed version:
def plus(pl):
    if len(pl) == 1:
        return pl[0]
    pl.sort()
    tmp = pl.pop(0)
    while len(pl) > 1:
        tmp2 = pl.pop(0)
        print(tmp, tmp2)
        tmp -= tmp2
    print(pl[0], tmp)
    return pl[0]-tmp


def minas(mi):
    if len(mi) == 1:
        return mi[0]
    mi.sort()
    tmp = mi.pop()
    while len(mi) > 1:
        tmp2 = mi.pop()
        print(tmp, tmp2)
        tmp -= tmp2
    print(tmp, mi[0])
    return tmp-mi[0]


n = int(input())

mi = []
pl = []

for i in [int(j) for j in input().split()]:
    if i < 0:
        mi.append(i)
    else:
        pl.append(i)

if len(pl) == 0:
    print(2*max(mi)-sum(mi))
    minas(mi)
elif len(mi) == 0:
    print(sum(pl)-2*min(pl))
    plus(pl)
else:
    print(abs(sum(mi))+sum(pl))
    mi.sort()
    pl.sort(reverse=True)
    while len(pl) > 1:
        tmp = pl.pop()
        print(mi[0], tmp)
        mi[0] -= tmp

    while len(mi) > 1:
        tmp = mi.pop()
        print(pl[0], tmp)
        pl[0] -= tmp

    print(pl[0], mi[0])

# Buggy version:
n = int(input())
alist = list(map(int,input().split()))
ans = []

if len(alist) == 2:
    alist.sort(reverse = True)
    print(alist[0]-alist[1])
    print(' '.join(map(str,alist)))
else:
    plus =[w for w in alist if w>=0]
    minus =[x for x in alist if x<0]
    if minus == []:
        plus.sort()
        for y in range(len(plus)-2):
            ans.append(' '.join(map(str,plus[y:y+2])))
            plus[y+1] = plus[y]-plus[y+1]
        pplus = plus[::-1]
        ans.append(' '.join(map(str,pplus[0:2])))
        print(pplus[0]-pplus[1])
        for y in ans:
            print(y)

# Fixed version:
n = int(input())
alist = list(map(int,input().split()))
ans = []

if len(alist) == 2:
    alist.sort(reverse = True)
    print(alist[0]-alist[1])
    print(' '.join(map(str,alist)))
else:
    plus =[w for w in alist if w>=0]
    minus =[x for x in alist if x<0]
    if minus == []:
        plus.sort()
        for y in range(len(plus)-2):
            ans.append(' '.join(map(str,plus[y:y+2])))
            plus[y+1] = plus[y]-plus[y+1]
        pplus = plus[::-1]
        ans.append(' '.join(map(str,pplus[0:2])))
        print(pplus[0]-pplus[1])
        for y in ans:
            print(y)
    elif plus == []:
        minus.sort(reverse = True)
        for y in range(len(minus)-1):
            ans.append(' '.join(map(str,minus[y:y+2])))
            minus[y+1] = minus[y]-minus[y+1]
        print(minus[-1])
        for y in ans:
            print(y)
    else:
        for z in range(len(plus)-1):
            ans.append(' '.join(map(str,[minus[0],plus[z]])))
            minus[0] = minus[0]-plus[z]
        for q in minus:
            ans.append(' '.join(map(str,[plus[-1],q])))
            plus[-1] = plus[-1]-q
        print(plus[-1])
        for t in ans:
            print(t)

# Buggy version:
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

L = [a for a in A if a <= 0]
R = [a for a in A if a > 0]

if L != [] and R != []:
    low = L[0]
    for r in R[:-1]:
        print(low, r)
        low -= r

    up = R[-1]
    for l in L[1:]:
        print(up, l)
        up -= l

    print(up, low)
    print(up - low)

elif L == []:
    low, up = R[0], R[-1]
    for r in R[1:-1]:
        print(low, r)
        low -= r
    print(up, low)
    print(up - low)

elif R == []:
    low, up = L[0], L[-1]
    for l in L[1:-1]:
        print(up, l)
        up -= l
    print(up, low)
    print(up - low)



# Fixed version:
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

L = [a for a in A if a <= 0]
R = [a for a in A if a > 0]

ans = []

if L != [] and R != []:
    low = L[0]
    for r in R[:-1]:
        ans.append([low, r])
        low -= r

    up = R[-1]
    for l in L[1:]:
        ans.append([up, l])
        up -= l

    ans.append([up, low])
    ans.append([up - low])

elif L == []:
    low, up = R[0], R[-1]
    for r in R[1:-1]:
        ans.append([low, r])
        low -= r
    ans.append([up, low])
    ans.append([up - low])

elif R == []:
    low, up = L[0], L[-1]
    for l in L[1:-1]:
        ans.append([up, l])
        up -= l
    ans.append([up, low])
    ans.append([up - low])

print(*ans[-1])
for a in ans[:-1]:
    print(*a)

# Buggy version:
N = int(input())
A_lis = list(map(int, input().split()))

A_lis.sort()

N_neg = 0
for j in A_lis:
  if j < 0:
    N_neg += 1
  else:
    break

N_pos = len(A_lis) - N_neg

seq = []

neg = A_lis[0]

for j in range(N_pos-1):
  ind = N_neg + j
  seq.append((neg, A_lis[ind]))
  neg = neg - A_lis[ind]

pos = A_lis[-1]
  
for j in range(N_neg-1):
  ind = j + 1
  seq.append((pos, A_lis[ind]))
  pos = pos - A_lis[ind]
  
seq.append((pos, neg))
print(pos-neg)

for j in seq:
  print("%d %d" % j)


# Fixed version:
N = int(input())
A_lis = list(map(int, input().split()))

A_lis.sort()

N_neg = 0
for j in A_lis:
  if j < 0:
    N_neg += 1
  else:
    break
    
N_pos = len(A_lis) - N_neg

seq = []

neg = A_lis[0]
pos = A_lis[-1]

if N_neg == 0:
  for j in range(N_pos-2):
    ind = j + 1
    seq.append((neg, A_lis[ind]))
    neg = neg - A_lis[ind]
  seq.append((pos, neg))
  print(pos-neg)
  for j in seq:
    print("%d %d" % j)
  exit()
  
if N_pos == 0:
  for j in range(N_neg-1):
    ind = j
    seq.append((pos, A_lis[ind]))
    pos = pos - A_lis[ind]
  print(pos)
  for j in seq:
    print("%d %d" % j)
  exit()
    
for j in range(N_pos-1):
  ind = N_neg + j
  seq.append((neg, A_lis[ind]))
  neg = neg - A_lis[ind]

  
for j in range(N_neg-1):
  ind = j + 1
  seq.append((pos, A_lis[ind]))
  pos = pos - A_lis[ind]
  
seq.append((pos, neg))
print(pos-neg)

for j in seq:
  print("%d %d" % j)

# Buggy version:
N = int(input())
A = list(map(int, input().split()))

A.sort()
MAX = A.pop(-1)
ans = MAX
MIN = A.pop(0)
if MIN <= 0:
    if N == 2:
        ans -= MIN
        print("{0} {1}".format(MAX, MIN))
    else:
        
        for a in A:
            if a > 0:
                print("{0} {1}".format(MIN, a))
                MIN -= a
            else:
                print("{0} {1}".format(MAX, a))
                MAX -= a
        print("{0} {1}".format(MAX, MIN))
else:
    if N == 2:
        ans -= MIN
        print("{0} {1}".format(MAX, MIN))
    else:
        b = A.pop(-1)
        print("{0} {1}".format(MIN, b))
        MIN -= b
        for a in A:
            if a > 0:
                print("{0} {1}".format(MIN, a))
                MIN -= a
            else:
                print("{0} {1}".format(MAX, a))
                MAX -= a
        print("{0} {1}".format(MAX, MIN))


# Fixed version:
N = int(input())
A = list(map(int, input().split()))

A.sort()
MAX = A.pop(-1)
ans = MAX
MIN = A.pop(0)
MIN2 = MIN
MAX2 = MAX

if MIN2 <= 0:
    if N == 2:
        ans -= MIN2
    else:
        for a in A:
            if a > 0:
                MIN2 -= a
            else:
                
                MAX2 -= a
        ans = MAX2 - MIN2
       
        
else:
    if N == 2:
        ans -= MIN2
        
    else:
        b = A.pop(-1)
        
        MIN2 -= b
        for a in A:
            if a > 0:
                
                MIN2 -= a
            else:
                
                MAX2 -= a
        ans = MAX2 - MIN2

print(ans)

if MIN <= 0:
    if N == 2:
        ans -= MIN
        print("{0} {1}".format(MAX, MIN))
    else:
        
        for a in A:
            if a > 0:
                print("{0} {1}".format(MIN, a))
                MIN -= a
            else:
                print("{0} {1}".format(MAX, a))
                MAX -= a
        print("{0} {1}".format(MAX, MIN))
        
else:
    if N == 2:
        ans -= MIN
        print("{0} {1}".format(MAX, MIN))
    else:
      
        print("{0} {1}".format(MIN, b))
        MIN -= b
        for a in A:
            if a > 0:
                print("{0} {1}".format(MIN, a))
                MIN -= a
            else:
                print("{0} {1}".format(MAX, a))
                MAX -= a
        print("{0} {1}".format(MAX, MIN))

# Buggy version:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
print(a)

if a[-1] < 0:
    ans = a[-1]
    for i in range(0,n-1):
        ans = ans - a[i]
    print(ans)

    ko = a[-1]
    for i in range(0,n-1):
        print(ko,a[i])
        ko = ko-a[i]

elif a[0] < 0:
    ans = 0
    negn = 0
    for i in range(n):
        ans += abs(a[i])
        if a[i]<0:
            negn += 1
    print(ans)
    s = a[0]
    for i in range(negn , n-1):
        print(s,a[i])
        s = s-a[i]
    k = a[-1]
    for i in range(1,negn):
        print(k,a[i])
        k = k-a[i]
    print(k,s)

else:
    ans = 0
    for i in range(n):
        ans += abs(a[i])
    print(ans-2*a[0])
    m = a[0]
    for i in range(1,n-1):
        print(m,a[i])
        m = m-a[i]
    print(a[-1],m)


# Fixed version:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
#print(a)

if a[-1] < 0:
    ans = a[-1]
    for i in range(0,n-1):
        ans = ans - a[i]
    print(ans)

    ko = a[-1]
    for i in range(0,n-1):
        print(ko,a[i])
        ko = ko-a[i]

elif a[0] < 0:
    ans = 0
    negn = 0
    for i in range(n):
        ans += abs(a[i])
        if a[i]<0:
            negn += 1
    print(ans)
    s = a[0]
    for i in range(negn , n-1):
        print(s,a[i])
        s = s-a[i]
    k = a[-1]
    for i in range(1,negn):
        print(k,a[i])
        k = k-a[i]
    print(k,s)

else:
    ans = 0
    for i in range(n):
        ans += abs(a[i])
    print(ans-2*a[0])
    m = a[0]
    for i in range(1,n-1):
        print(m,a[i])
        m = m-a[i]
    print(a[-1],m)

# Buggy version:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AM = A.pop(0)
xy = []
if AM > 0 and A[-1] >= 0:
    p = 1
elif AM <= 0 and A[-1] < 0:
    p = 2
else:
    p = 3
if p == 1:
    while(len(A)>1):
        x = A.pop(-1)
        y = A.pop(0)
        xy.append([x, y])
        A.append(x-y)
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 2:
    while(len(A)>1):
        x = AM
        y = A.pop(-1)
        xy.append([x, y])
        AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 3:
    while(len(A)>1):
        y = A.pop(0)
        if y >= 0:
            x = A.pop(-1)
            xy.append([x, y])
            xy.append([x, y])
            A.append(x-y)
        else:
            x = AM
            xy.append([x, y])
            AM -= y
            xy.append([AM, A[0]])
            ans = AM - A[0]
print(ans)
for out in xy:
    print(*out)

# Fixed version:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
AM = A.pop(0)
xy = []
if AM > 0 and A[-1] >= 0:
    p = 1
elif AM <= 0 and A[-1] < 0:
    p = 2
else:
    p = 3
if p == 1:
    while(len(A)>1):
        x = A.pop(-1)
        y = A.pop(0)
        xy.append([x, y])
        A.append(x-y)
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 2:
    while(len(A)>1):
        x = AM
        y = A.pop(-1)
        xy.append([x, y])
        AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
if p == 3:
    while(len(A)>1):
        y = A.pop(0)
        if y >= 0:
            x = A.pop(-1)
            xy.append([x, y])
            A.append(x-y)
        else:
            x = AM
            xy.append([x, y])
            AM -= y
    xy.append([AM, A[0]])
    ans = AM - A[0]
print(ans)
for out in xy:
    print(*out)

# Buggy version:
import bisect 

n=int(input())
l=list(map(int,input().split()))
l.sort()
#dq=deque(l)
if l[0]>=0:
    print('hello')
    a=l[0]
    ans=0
    for i in range(n):
        ans+=l[i]
    print(ans-2*l[0])
    for i in range(1,n-1):
        print(a,l[i])
        a-=l[i]
    print(l[-1],a)
elif l[-1]<=0:
    #print('hello')
    a=l[-1]
    ans=l[-1]
    for i in range(n-1):
        ans-=l[i]
    print(ans)
    for i in range(n-1):
        print(a,l[i])
        a-=l[i]
else:
    #print('hello')
    idx=bisect.bisect(l,0)
    ans=0
    for i in range(n):
        if l[i]>=0:
            ans+=l[i]
        else:
            ans-=l[i]
    print(ans)
    a=l[0]
    for i in range(idx,n-1):
        print(a,l[i])
        a-=l[i]
    for i in range(1,a):
        print(l[-1],l[i])
    print(l[-1],a)

# Fixed version:
import bisect 

n=int(input())
l=list(map(int,input().split()))
l.sort()
if l[0]>=0:
    #print('hello')
    a=l[0]
    ans=0
    for i in range(n):
        ans+=l[i]
    print(ans-2*l[0])
    for i in range(1,n-1):
        print(a,l[i])
        a-=l[i]
    print(l[-1],a)
elif l[-1]<=0:
    #print('hello')
    a=l[-1]
    ans=l[-1]
    for i in range(n-1):
        ans-=l[i]
    print(ans)
    for i in range(n-1):
        print(a,l[i])
        a-=l[i]
else:
    #print('hello')
    idx=bisect.bisect(l,0)
    ans=0
    for i in range(n):
        if l[i]>=0:
            ans+=l[i]
        else:
            ans-=l[i]
    print(ans)
    a=l[0]
    for i in range(idx,n-1):
        print(a,l[i])
        a-=l[i]
    b=l[-1]
    for i in range(1,idx):
        print(b,l[i])
        b-=l[i]
        
    print(b,a)

# Buggy version:
import collections

def solve():
  n = int(input())
  a = collections.deque(sorted(list(int(i) for i in input().split())))
  big = a.pop()
  mini = a.popleft()
  queue = collections.deque([])
  #print(big,mini)
  while (a):
    if a[0] <= 0:
      tmp = a.popleft()
      queue.append((big,tmp))
      big -= tmp
    else:
      tmp = a.pop()
      queue.append((tmp,mini))
      mini -= tmp
  print(big-mini)
  queue.append((big,mini))
  for i in range(len(queue)):
    print(*queue[i])
  
solve()


# Fixed version:
import collections

def solve():
  n = int(input())
  a = collections.deque(sorted(list(int(i) for i in input().split())))
  big = a.pop()
  mini = a.popleft()
  queue = collections.deque([])
  #print(big,mini)
  while (a):
    if a[0] <= 0:
      tmp = a.popleft()
      queue.append((big,tmp))
      big -= tmp
    else:
      tmp = a.pop()
      queue.append((mini,tmp))
      mini -= tmp
  print(big-mini)
  queue.append((big,mini))
  for i in range(len(queue)):
    print(*queue[i])
  
solve()

# Buggy version:
n=int(input())
a=sorted(map(int, input().split()))
a1=[i for i in a if i>=0]
a2=[i for i in a if i<0]
if a1 and a2:
    print(sum(a1)-sum(a2))
    mx,mn=a1[-1], a2[0]
    for i in a1[:-1]:
        print(i,mn)
        mn-=i
    for i in a2[1:]:
        print(mx,i)
        mx-=i
    print(mx,mn)
elif not a2:
    print(sum(a1[1:])-a1[0])
    mx,mn=a1[-1], a1[0]
    for i in a1[1:-1]:
        print(i,mn)
        mn-=i
    print(mx,mn)
else:
    print(a2[-1]-sum(a2[:-1]))
    mx,mn=a2[-1], a2[0]
    for i in a2[1:-1]:
        print(mx,i)
        mx-=i
    print(mx,mn)

# Fixed version:
n=int(input())
a=sorted(map(int, input().split()))
a1=[i for i in a if i>=0]
a2=[i for i in a if i<0]
if a1 and a2:
    print(sum(a1)-sum(a2))
    mx,mn=a1[-1], a2[0]
    for i in a1[:-1]:
        print(mn,i)
        mn-=i
    for i in a2[1:]:
        print(mx,i)
        mx-=i
    print(mx,mn)
elif not a2:
    print(sum(a1[1:])-a1[0])
    mx,mn=a1[-1], a1[0]
    for i in a1[1:-1]:
        print(mn,i)
        mn-=i
    print(mx,mn)
else:
    print(a2[-1]-sum(a2[:-1]))
    mx,mn=a2[-1], a2[0]
    for i in a2[1:-1]:
        print(mx,i)
        mx-=i
    print(mx,mn)

# Buggy version:
n=int(input())
a=list(map(int,input().split()))
a.sort()
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:print(ma,i);ma-=i
  else:print(mi,i);mi-=i
print(ma,mi)

# Fixed version:
n=int(input())
a=list(map(int,input().split()))
a.sort()
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:ma-=i
  else:mi-=i
print(ma-mi)
mi,ma=a[0],a[-1]
for i in a[1:-1]:
  if i<0:print(ma,i);ma-=i
  else:print(mi,i);mi-=i
print(ma,mi)