#!/usr/bin/env python3
#diverta2019_2 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = a[-1]
mi = a[0]
log = []
for i in a[1:-1]:
    if i >= 0:
        log.append([mi,i])
        mi -= i
    else:
        log.append([ma,i])
        ma -= i
log.append([ma,mi])
print(ma-mi)
for i in range(n-1):
    x,y = log[i]
    print(x,y) import sys sys import math math import bisect bisect sys.setrecursionlimit(1000000000) sys.setrecursionlimit sys setrecursionlimit 1000000000 from heapq import heappush, heappop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations 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 ma = a[-1] ma a[-1] a -1 mi = a[0] mi a[0] a 0 log = [] log [] for i in a[1:-1]:
    if i >= 0:
        log.append([mi,i])
        mi -= i
    else:
        log.append([ma,i])
        ma -= i i a[1:-1] a 1:-1 1 -1 if i >= 0:
        log.append([mi,i])
        mi -= i
    else:
        log.append([ma,i])
        ma -= i i >= 0 i 0 log.append([mi,i]) log.append log append [mi,i] mi i mi -= i mi i log.append([ma,i]) log.append log append [ma,i] ma i ma -= i ma i log.append([ma,mi]) log.append log append [ma,mi] ma mi print(ma-mi) print ma-mi ma mi for i in range(n-1):
    x,y = log[i]
    print(x,y) i range(n-1) range n-1 n 1 x,y = log[i] x log[i] log i y print(x,y) print x y log = [] [] log y = log[i] log[i] y ma -= i i ma mod = 10**9 + 7 10**9 + 7 mod n = int(input()) int(input()) n a = list(map(int,input().split())) list(map(int,input().split())) a x,y = log[i] log[i] x mi -= i i mi ma = a[-1] a[-1] ma mi = a[0] a[0] mi
#!/usr/bin/env python3
#diverta2019_2 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = a[-1]
mi = a[0]
log = []
for i in a[1:-1]:
    if i >= 0:
        log.append([mi,i])
        mi -= i
    else:
        log.append([ma,i])
        ma -= i
log.append([ma,mi])
print(ma-mi)
for i in range(n-1):
    x,y = log[i]
    print(x,y)
