# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
a.sort()
minnum = a[0]
maxnum = a[-1]
zind = bisect.bisect_left(a, 0)
ans = []
ansnum = maxnum
if zind == n:
    zind-=1
for i in range(1,zind):
    tmp = a[i]
    ans.append([maxnum, tmp])
    ansnum-=tmp
    maxnum-=tmp
ansnum -= minnum
if zind == 0:
    zind+=1
for i in range(zind, n-1):
    tmp = a[i]
    ans.append([minnum, tmp])
    ansnum+=tmp
    minnum-=tmp
ans.append([maxnum, minnum])
print(ansnum)
for p in ans:
    print(*p, sep = ' ') import math math import sys sys import bisect bisect import heapq heapq from collections import deque inf = 10**18 inf 10**18 10 18 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 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 minnum = a[0] minnum a[0] a 0 maxnum = a[-1] maxnum a[-1] a -1 zind = bisect.bisect_left(a, 0) zind bisect.bisect_left(a, 0) bisect.bisect_left bisect bisect_left a 0 ans = [] ans [] ansnum = maxnum ansnum maxnum if zind == n:
    zind-=1 zind == n zind n zind-=1 zind 1 for i in range(1,zind):
    tmp = a[i]
    ans.append([maxnum, tmp])
    ansnum-=tmp
    maxnum-=tmp i range(1,zind) range 1 zind tmp = a[i] tmp a[i] a i ans.append([maxnum, tmp]) ans.append ans append [maxnum, tmp] maxnum tmp ansnum-=tmp ansnum tmp maxnum-=tmp maxnum tmp ansnum -= minnum ansnum minnum if zind == 0:
    zind+=1 zind == 0 zind 0 zind+=1 zind 1 for i in range(zind, n-1):
    tmp = a[i]
    ans.append([minnum, tmp])
    ansnum+=tmp
    minnum-=tmp i range(zind, n-1) range zind n-1 n 1 tmp = a[i] tmp a[i] a i ans.append([minnum, tmp]) ans.append ans append [minnum, tmp] minnum tmp ansnum+=tmp ansnum tmp minnum-=tmp minnum tmp ans.append([maxnum, minnum]) ans.append ans append [maxnum, minnum] maxnum minnum print(ansnum) print ansnum for p in ans:
    print(*p, sep = ' ') p ans print(*p, sep = ' ') print *p p sep = ' ' sep ' ' minnum = a[0] a[0] minnum maxnum = a[-1] a[-1] maxnum maxnum-=tmp tmp maxnum a = list(map(int, input().split())) list(map(int, input().split())) a zind+=1 1 zind tmp = a[i] a[i] tmp inf = 10**18 10**18 inf mod = 10**9+7 10**9+7 mod minnum-=tmp tmp minnum n = int(input()) int(input()) n zind = bisect.bisect_left(a, 0) bisect.bisect_left(a, 0) zind zind-=1 1 zind ansnum -= minnum minnum ansnum ansnum-=tmp tmp ansnum ansnum = maxnum maxnum ansnum ansnum+=tmp tmp ansnum tmp = a[i] a[i] tmp ans = [] [] ans
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
a.sort()
minnum = a[0]
maxnum = a[-1]
zind = bisect.bisect_left(a, 0)
ans = []
ansnum = maxnum
if zind == n:
    zind-=1
for i in range(1,zind):
    tmp = a[i]
    ans.append([maxnum, tmp])
    ansnum-=tmp
    maxnum-=tmp
ansnum -= minnum
if zind == 0:
    zind+=1
for i in range(zind, n-1):
    tmp = a[i]
    ans.append([minnum, tmp])
    ansnum+=tmp
    minnum-=tmp
ans.append([maxnum, minnum])
print(ansnum)
for p in ans:
    print(*p, sep = ' ')