N = int(input())
*A, = map(int, input().split())
operations = []
pos = []; zero = []; neg = [];
for a in A:
    if a > 0: pos.append(a)
    elif a == 0: zero.append(a)
    else: neg.append(a)
pos.sort(); neg.sort()
if N == 2:
    a, b = max(A), min(A)
    ans = a - b
    operations.append((a, b))
else:
    if len(neg) == 0:
        pos = zero + pos
        operations.append((pos[0], pos[-1]))
        neg = [pos[0] - pos[-1]]
        pos = pos[1:-1]
    elif len(pos) == 0:
        neg = neg + zero
        operations.append((neg[-1], neg[0]))
        pos = [neg[-1] - neg[0]]
        neg = neg[1:-1]
    else:
        neg = neg + zero
    neg = neg[::-1]
    while len(pos) > 1 and len(neg) > 1:
        n, p = neg.pop(), pos.pop()
        operations.append((p, n))
        pos.append(p-n)
    if len(neg) == 1:
        while len(pos) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((n, p))
            neg.append(n-p)
    else:
        while len(neg) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((p, n))
            pos.append(p-n)
    operations.append((pos[0], neg[0]))
    ans = pos[0] - neg[0]
print(ans)
for x, y in operations:
    print(x, y) N = int(input()) N int(input()) int input() input *A, = map(int, input().split()) *A A map(int, input().split()) map int input().split() ().split () input split operations = [] operations [] pos = [] pos [] zero = [] zero [] neg = [] neg [] for a in A:
    if a > 0: pos.append(a)
    elif a == 0: zero.append(a)
    else: neg.append(a) a A if a > 0: pos.append(a)
    elif a == 0: zero.append(a)
    else: neg.append(a) a > 0 a 0 elif a == 0: zero.append(a)
     a == 0 a 0 pos.sort() pos.sort pos sort neg.sort() neg.sort neg sort if N == 2:
    a, b = max(A), min(A)
    ans = a - b
    operations.append((a, b))
else:
    if len(neg) == 0:
        pos = zero + pos
        operations.append((pos[0], pos[-1]))
        neg = [pos[0] - pos[-1]]
        pos = pos[1:-1]
    elif len(pos) == 0:
        neg = neg + zero
        operations.append((neg[-1], neg[0]))
        pos = [neg[-1] - neg[0]]
        neg = neg[1:-1]
    else:
        neg = neg + zero
    neg = neg[::-1]
    while len(pos) > 1 and len(neg) > 1:
        n, p = neg.pop(), pos.pop()
        operations.append((p, n))
        pos.append(p-n)
    if len(neg) == 1:
        while len(pos) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((n, p))
            neg.append(n-p)
    else:
        while len(neg) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((p, n))
            pos.append(p-n)
    operations.append((pos[0], neg[0]))
    ans = pos[0] - neg[0] N == 2 N 2 a, b = max(A), min(A) a max(A) max A b min(A) min A ans = a - b ans a - b a b operations.append((a, b)) operations.append operations append (a, b) a b if len(neg) == 0:
        pos = zero + pos
        operations.append((pos[0], pos[-1]))
        neg = [pos[0] - pos[-1]]
        pos = pos[1:-1]
    elif len(pos) == 0:
        neg = neg + zero
        operations.append((neg[-1], neg[0]))
        pos = [neg[-1] - neg[0]]
        neg = neg[1:-1]
    else:
        neg = neg + zero
     len(neg) == 0 len(neg) len neg 0 pos = zero + pos pos zero + pos zero pos operations.append((pos[0], pos[-1])) operations.append operations append (pos[0], pos[-1]) pos[0] pos 0 pos[-1] pos -1 neg = [pos[0] - pos[-1]] neg [pos[0] - pos[-1]] pos[0] - pos[-1] pos[0] pos 0 pos[-1] pos -1 pos = pos[1:-1] pos pos[1:-1] pos 1:-1 1 -1 elif len(pos) == 0:
        neg = neg + zero
        operations.append((neg[-1], neg[0]))
        pos = [neg[-1] - neg[0]]
        neg = neg[1:-1]
     len(pos) == 0 len(pos) len pos 0 neg = neg + zero neg neg + zero neg zero operations.append((neg[-1], neg[0])) operations.append operations append (neg[-1], neg[0]) neg[-1] neg -1 neg[0] neg 0 pos = [neg[-1] - neg[0]] pos [neg[-1] - neg[0]] neg[-1] - neg[0] neg[-1] neg -1 neg[0] neg 0 neg = neg[1:-1] neg neg[1:-1] neg 1:-1 1 -1 neg = neg + zero neg neg + zero neg zero neg = neg[::-1] neg neg[::-1] neg ::-1 -1 while len(pos) > 1 and len(neg) > 1:
        n, p = neg.pop(), pos.pop()
        operations.append((p, n))
        pos.append(p-n)
     len(pos) > 1 and len(neg) > 1 len(pos) > 1 len(pos) len pos 1 len(neg) > 1 len(neg) len neg 1 n, p = neg.pop(), pos.pop() n neg.pop() neg.pop neg pop p pos.pop() pos.pop pos pop operations.append((p, n)) operations.append operations append (p, n) p n pos.append(p-n) pos.append pos append p-n p n if len(neg) == 1:
        while len(pos) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((n, p))
            neg.append(n-p)
    else:
        while len(neg) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((p, n))
            pos.append(p-n)
     len(neg) == 1 len(neg) len neg 1 while len(pos) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((n, p))
            neg.append(n-p)
     len(pos) > 1 len(pos) len pos 1 n, p = neg.pop(), pos.pop() n neg.pop() neg.pop neg pop p pos.pop() pos.pop pos pop operations.append((n, p)) operations.append operations append (n, p) n p neg.append(n-p) neg.append neg append n-p n p while len(neg) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((p, n))
            pos.append(p-n)
     len(neg) > 1 len(neg) len neg 1 n, p = neg.pop(), pos.pop() n neg.pop() neg.pop neg pop p pos.pop() pos.pop pos pop operations.append((p, n)) operations.append operations append (p, n) p n pos.append(p-n) pos.append pos append p-n p n operations.append((pos[0], neg[0])) operations.append operations append (pos[0], neg[0]) pos[0] pos 0 neg[0] neg 0 ans = pos[0] - neg[0] ans pos[0] - neg[0] pos[0] pos 0 neg[0] neg 0 print(ans) print ans for x, y in operations:
    print(x, y) x y operations print(x, y) print x y pos = zero + pos zero + pos pos p = neg.pop(), pos.pop() pos.pop() p neg = neg + zero neg + zero neg n, p = neg.pop(), pos.pop() neg.pop() n neg = neg + zero neg + zero neg ans = pos[0] - neg[0] pos[0] - neg[0] ans n, p = neg.pop(), pos.pop() neg.pop() n neg = [pos[0] - pos[-1]] [pos[0] - pos[-1]] neg p = neg.pop(), pos.pop() pos.pop() p neg = [] [] neg b = max(A), min(A) min(A) b pos = pos[1:-1] pos[1:-1] pos N = int(input()) int(input()) N neg = neg[::-1] neg[::-1] neg p = neg.pop(), pos.pop() pos.pop() p ans = a - b a - b ans zero = [] [] zero pos = [neg[-1] - neg[0]] [neg[-1] - neg[0]] pos operations = [] [] operations n, p = neg.pop(), pos.pop() neg.pop() n pos = [] [] pos a, b = max(A), min(A) max(A) a neg = neg[1:-1] neg[1:-1] neg
N = int(input())
*A, = map(int, input().split())
operations = []
pos = []; zero = []; neg = [];
for a in A:
    if a > 0: pos.append(a)
    elif a == 0: zero.append(a)
    else: neg.append(a)
pos.sort(); neg.sort()
if N == 2:
    a, b = max(A), min(A)
    ans = a - b
    operations.append((a, b))
else:
    if len(neg) == 0:
        pos = zero + pos
        operations.append((pos[0], pos[-1]))
        neg = [pos[0] - pos[-1]]
        pos = pos[1:-1]
    elif len(pos) == 0:
        neg = neg + zero
        operations.append((neg[-1], neg[0]))
        pos = [neg[-1] - neg[0]]
        neg = neg[1:-1]
    else:
        neg = neg + zero
    neg = neg[::-1]
    while len(pos) > 1 and len(neg) > 1:
        n, p = neg.pop(), pos.pop()
        operations.append((p, n))
        pos.append(p-n)
    if len(neg) == 1:
        while len(pos) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((n, p))
            neg.append(n-p)
    else:
        while len(neg) > 1:
            n, p = neg.pop(), pos.pop()
            operations.append((p, n))
            pos.append(p-n)
    operations.append((pos[0], neg[0]))
    ans = pos[0] - neg[0]
print(ans)
for x, y in operations:
    print(x, y)