n = int(input())
a = list(map(int, input().split()))
arrays = []
a.sort()

b = []
c = []

for i in a:
    if i < 0:
        c.append(i)
    else:
        b.append(i)

if len(c) >= 1 and len(b) >= 1:
    while len(b) > 1:
        x = b.pop(0)
        array = [c[0], x]
        c[0] -= x
        arrays.append(array)
    while len(c) > 1:
        y = c.pop(0)
        array = [b[0], y]
        b[0] -= y
        arrays.append(array)

    array = [b[0], c[0]]
    arrays.append(array)

    print(b[0] - c[0])

elif len(b) == 0 and len(c) >= 1:
    mi = c.pop(-1)
    while len(c) > 1:
        x = c.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [mi, c[0]]
    arrays.append(array)
    print(mi - c[0])


elif len(b) >= 1 and len(c) == 0:
    mi = b.pop(0)
    while len(b) > 1:
        x = b.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [b[0], mi]
    arrays.append(array)
    print(b[0]-mi)


for x, y in arrays:
    print(x, y)
 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 arrays = [] arrays [] a.sort() a.sort a sort b = [] b [] c = [] c [] for i in a:
    if i < 0:
        c.append(i)
    else:
        b.append(i) i a if i < 0:
        c.append(i)
    else:
        b.append(i) i < 0 i 0 c.append(i) c.append c append i b.append(i) b.append b append i if len(c) >= 1 and len(b) >= 1:
    while len(b) > 1:
        x = b.pop(0)
        array = [c[0], x]
        c[0] -= x
        arrays.append(array)
    while len(c) > 1:
        y = c.pop(0)
        array = [b[0], y]
        b[0] -= y
        arrays.append(array)

    array = [b[0], c[0]]
    arrays.append(array)

    print(b[0] - c[0])

elif len(b) == 0 and len(c) >= 1:
    mi = c.pop(-1)
    while len(c) > 1:
        x = c.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [mi, c[0]]
    arrays.append(array)
    print(mi - c[0])


elif len(b) >= 1 and len(c) == 0:
    mi = b.pop(0)
    while len(b) > 1:
        x = b.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [b[0], mi]
    arrays.append(array)
    print(b[0]-mi) len(c) >= 1 and len(b) >= 1 len(c) >= 1 len(c) len c 1 len(b) >= 1 len(b) len b 1 while len(b) > 1:
        x = b.pop(0)
        array = [c[0], x]
        c[0] -= x
        arrays.append(array)
     len(b) > 1 len(b) len b 1 x = b.pop(0) x b.pop(0) b.pop b pop 0 array = [c[0], x] array [c[0], x] c[0] c 0 x c[0] -= x c[0] c 0 x arrays.append(array) arrays.append arrays append array while len(c) > 1:
        y = c.pop(0)
        array = [b[0], y]
        b[0] -= y
        arrays.append(array)

     len(c) > 1 len(c) len c 1 y = c.pop(0) y c.pop(0) c.pop c pop 0 array = [b[0], y] array [b[0], y] b[0] b 0 y b[0] -= y b[0] b 0 y arrays.append(array) arrays.append arrays append array array = [b[0], c[0]] array [b[0], c[0]] b[0] b 0 c[0] c 0 arrays.append(array) arrays.append arrays append array print(b[0] - c[0]) print b[0] - c[0] b[0] b 0 c[0] c 0 elif len(b) == 0 and len(c) >= 1:
    mi = c.pop(-1)
    while len(c) > 1:
        x = c.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [mi, c[0]]
    arrays.append(array)
    print(mi - c[0]) len(b) == 0 and len(c) >= 1 len(b) == 0 len(b) len b 0 len(c) >= 1 len(c) len c 1 mi = c.pop(-1) mi c.pop(-1) c.pop c pop -1 while len(c) > 1:
        x = c.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
     len(c) > 1 len(c) len c 1 x = c.pop(0) x c.pop(0) c.pop c pop 0 array = [mi, x] array [mi, x] mi x mi -= x mi x arrays.append(array) arrays.append arrays append array array = [mi, c[0]] array [mi, c[0]] mi c[0] c 0 arrays.append(array) arrays.append arrays append array print(mi - c[0]) print mi - c[0] mi c[0] c 0 elif len(b) >= 1 and len(c) == 0:
    mi = b.pop(0)
    while len(b) > 1:
        x = b.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [b[0], mi]
    arrays.append(array)
    print(b[0]-mi) len(b) >= 1 and len(c) == 0 len(b) >= 1 len(b) len b 1 len(c) == 0 len(c) len c 0 mi = b.pop(0) mi b.pop(0) b.pop b pop 0 while len(b) > 1:
        x = b.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
     len(b) > 1 len(b) len b 1 x = b.pop(0) x b.pop(0) b.pop b pop 0 array = [mi, x] array [mi, x] mi x mi -= x mi x arrays.append(array) arrays.append arrays append array array = [b[0], mi] array [b[0], mi] b[0] b 0 mi arrays.append(array) arrays.append arrays append array print(b[0]-mi) print b[0]-mi b[0] b 0 mi for x, y in arrays:
    print(x, y) x y arrays print(x, y) print x y mi -= x x mi arrays = [] [] arrays b = [] [] b array = [b[0], y] [b[0], y] array array = [b[0], c[0]] [b[0], c[0]] array n = int(input()) int(input()) n a = list(map(int, input().split())) list(map(int, input().split())) a x = c.pop(0) c.pop(0) x array = [mi, x] [mi, x] array mi -= x x mi mi = c.pop(-1) c.pop(-1) mi array = [mi, c[0]] [mi, c[0]] array c = [] [] c x = b.pop(0) b.pop(0) x array = [b[0], mi] [b[0], mi] array y = c.pop(0) c.pop(0) y array = [mi, x] [mi, x] array x = b.pop(0) b.pop(0) x array = [c[0], x] [c[0], x] array mi = b.pop(0) b.pop(0) mi
n = int(input())
a = list(map(int, input().split()))
arrays = []
a.sort()

b = []
c = []

for i in a:
    if i < 0:
        c.append(i)
    else:
        b.append(i)

if len(c) >= 1 and len(b) >= 1:
    while len(b) > 1:
        x = b.pop(0)
        array = [c[0], x]
        c[0] -= x
        arrays.append(array)
    while len(c) > 1:
        y = c.pop(0)
        array = [b[0], y]
        b[0] -= y
        arrays.append(array)

    array = [b[0], c[0]]
    arrays.append(array)

    print(b[0] - c[0])

elif len(b) == 0 and len(c) >= 1:
    mi = c.pop(-1)
    while len(c) > 1:
        x = c.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [mi, c[0]]
    arrays.append(array)
    print(mi - c[0])


elif len(b) >= 1 and len(c) == 0:
    mi = b.pop(0)
    while len(b) > 1:
        x = b.pop(0)
        array = [mi, x]
        mi -= x
        arrays.append(array)
    array = [b[0], mi]
    arrays.append(array)
    print(b[0]-mi)


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

