import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

a.sort()

from bisect import bisect_left
from bisect import bisect_right

pos = n - bisect_left(a, 1)
neg = bisect_right(a, -1)


ans_exec = []

if pos>=neg:
    aa = a[max(0,neg-1):n-neg+1]
    for i in range(neg-1):
        ans_exec.append((a[-1-i], a[i]))
        aa.append(a[-1-i] - a[i])
    aa.sort()
    tmp = aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans_exec.append((aa[-1], tmp))
    ans = aa[-1] - tmp

elif pos<=neg:
    aa = a[max(0,pos-1):n-pos+1]
    for i in range(pos-1):
        ans_exec.append((a[i], a[-1-i]))
        aa.append(a[i] - a[-1-i])
    aa.sort()
    tmp = aa[-1]
    ans_exec.append((aa[-1], aa[0]))
    tmp = aa[-1]-aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans = tmp


print(ans)
for a,b in ans_exec:
    print(a,b) import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 bisect import bisect_left from bisect import bisect_right pos = n - bisect_left(a, 1) pos n - bisect_left(a, 1) n bisect_left(a, 1) bisect_left a 1 neg = bisect_right(a, -1) neg bisect_right(a, -1) bisect_right a -1 ans_exec = [] ans_exec [] if pos>=neg:
    aa = a[max(0,neg-1):n-neg+1]
    for i in range(neg-1):
        ans_exec.append((a[-1-i], a[i]))
        aa.append(a[-1-i] - a[i])
    aa.sort()
    tmp = aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans_exec.append((aa[-1], tmp))
    ans = aa[-1] - tmp

elif pos<=neg:
    aa = a[max(0,pos-1):n-pos+1]
    for i in range(pos-1):
        ans_exec.append((a[i], a[-1-i]))
        aa.append(a[i] - a[-1-i])
    aa.sort()
    tmp = aa[-1]
    ans_exec.append((aa[-1], aa[0]))
    tmp = aa[-1]-aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans = tmp pos>=neg pos neg aa = a[max(0,neg-1):n-neg+1] aa a[max(0,neg-1):n-neg+1] a max(0,neg-1):n-neg+1 max(0,neg-1) max 0 neg-1 neg 1 n-neg+1 n-neg n neg 1 for i in range(neg-1):
        ans_exec.append((a[-1-i], a[i]))
        aa.append(a[-1-i] - a[i])
     i range(neg-1) range neg-1 neg 1 ans_exec.append((a[-1-i], a[i])) ans_exec.append ans_exec append (a[-1-i], a[i]) a[-1-i] a -1-i -1 i a[i] a i aa.append(a[-1-i] - a[i]) aa.append aa append a[-1-i] - a[i] a[-1-i] a -1-i -1 i a[i] a i aa.sort() aa.sort aa sort tmp = aa[0] tmp aa[0] aa 0 for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
     i range(1,len(aa)-1) range 1 len(aa)-1 len(aa) len aa 1 ans_exec.append((tmp, aa[i])) ans_exec.append ans_exec append (tmp, aa[i]) tmp aa[i] aa i tmp = tmp-aa[i] tmp tmp-aa[i] tmp aa[i] aa i ans_exec.append((aa[-1], tmp)) ans_exec.append ans_exec append (aa[-1], tmp) aa[-1] aa -1 tmp ans = aa[-1] - tmp ans aa[-1] - tmp aa[-1] aa -1 tmp elif pos<=neg:
    aa = a[max(0,pos-1):n-pos+1]
    for i in range(pos-1):
        ans_exec.append((a[i], a[-1-i]))
        aa.append(a[i] - a[-1-i])
    aa.sort()
    tmp = aa[-1]
    ans_exec.append((aa[-1], aa[0]))
    tmp = aa[-1]-aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans = tmp pos<=neg pos neg aa = a[max(0,pos-1):n-pos+1] aa a[max(0,pos-1):n-pos+1] a max(0,pos-1):n-pos+1 max(0,pos-1) max 0 pos-1 pos 1 n-pos+1 n-pos n pos 1 for i in range(pos-1):
        ans_exec.append((a[i], a[-1-i]))
        aa.append(a[i] - a[-1-i])
     i range(pos-1) range pos-1 pos 1 ans_exec.append((a[i], a[-1-i])) ans_exec.append ans_exec append (a[i], a[-1-i]) a[i] a i a[-1-i] a -1-i -1 i aa.append(a[i] - a[-1-i]) aa.append aa append a[i] - a[-1-i] a[i] a i a[-1-i] a -1-i -1 i aa.sort() aa.sort aa sort tmp = aa[-1] tmp aa[-1] aa -1 ans_exec.append((aa[-1], aa[0])) ans_exec.append ans_exec append (aa[-1], aa[0]) aa[-1] aa -1 aa[0] aa 0 tmp = aa[-1]-aa[0] tmp aa[-1]-aa[0] aa[-1] aa -1 aa[0] aa 0 for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
     i range(1,len(aa)-1) range 1 len(aa)-1 len(aa) len aa 1 ans_exec.append((tmp, aa[i])) ans_exec.append ans_exec append (tmp, aa[i]) tmp aa[i] aa i tmp = tmp-aa[i] tmp tmp-aa[i] tmp aa[i] aa i ans = tmp ans tmp print(ans) print ans for a,b in ans_exec:
    print(a,b) a b ans_exec print(a,b) print a b a = list( map(int, input().split())) list( map(int, input().split())) a ans_exec = [] [] ans_exec input = sys.stdin.readline sys.stdin.readline input tmp = aa[0] aa[0] tmp tmp = aa[-1] aa[-1] tmp tmp = tmp-aa[i] tmp-aa[i] tmp aa = a[max(0,pos-1):n-pos+1] a[max(0,pos-1):n-pos+1] aa tmp = aa[-1]-aa[0] aa[-1]-aa[0] tmp tmp = tmp-aa[i] tmp-aa[i] tmp neg = bisect_right(a, -1) bisect_right(a, -1) neg n = int(input()) int(input()) n ans = tmp tmp ans pos = n - bisect_left(a, 1) n - bisect_left(a, 1) pos aa = a[max(0,neg-1):n-neg+1] a[max(0,neg-1):n-neg+1] aa ans = aa[-1] - tmp aa[-1] - tmp ans
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
a = list( map(int, input().split()))

a.sort()

from bisect import bisect_left
from bisect import bisect_right

pos = n - bisect_left(a, 1)
neg = bisect_right(a, -1)


ans_exec = []

if pos>=neg:
    aa = a[max(0,neg-1):n-neg+1]
    for i in range(neg-1):
        ans_exec.append((a[-1-i], a[i]))
        aa.append(a[-1-i] - a[i])
    aa.sort()
    tmp = aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans_exec.append((aa[-1], tmp))
    ans = aa[-1] - tmp

elif pos<=neg:
    aa = a[max(0,pos-1):n-pos+1]
    for i in range(pos-1):
        ans_exec.append((a[i], a[-1-i]))
        aa.append(a[i] - a[-1-i])
    aa.sort()
    tmp = aa[-1]
    ans_exec.append((aa[-1], aa[0]))
    tmp = aa[-1]-aa[0]
    for i in range(1,len(aa)-1):
        ans_exec.append((tmp, aa[i]))
        tmp = tmp-aa[i]
    ans = tmp


print(ans)
for a,b in ans_exec:
    print(a,b)
