from collections import deque

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

A.sort()
A_d = deque(A)

if (A_d[0] <= 0 and A_d[n-1] > 0) or (A_d[0] < 0 and A_d[n-1] >= 0):
    print(sum(list(map(abs, A_d))))
    while A_d[-2] >= 0:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new)
elif A_d[0] > 0:
    atama = A_d.popleft()
    tugi = A_d.popleft()
    new = atama - tugi
    A_d.appendleft(new)
    print(sum(list(map(abs, A_d))))
    print(atama, tugi)
    while len(A_d) != 2:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    atama = A_d.popleft()
    ketu = A_d.pop()
    print(ketu, atama)
else:
    ketu = A_d.pop()
    tugi = A_d.pop()
    new = ketu - tugi
    A_d.append(new)
    print(sum(list(map(abs, A_d))))
    print(ketu, tugi)
    while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new) from collections import deque 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 A_d = deque(A) A_d deque(A) deque A if (A_d[0] <= 0 and A_d[n-1] > 0) or (A_d[0] < 0 and A_d[n-1] >= 0):
    print(sum(list(map(abs, A_d))))
    while A_d[-2] >= 0:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new)
elif A_d[0] > 0:
    atama = A_d.popleft()
    tugi = A_d.popleft()
    new = atama - tugi
    A_d.appendleft(new)
    print(sum(list(map(abs, A_d))))
    print(atama, tugi)
    while len(A_d) != 2:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    atama = A_d.popleft()
    ketu = A_d.pop()
    print(ketu, atama)
else:
    ketu = A_d.pop()
    tugi = A_d.pop()
    new = ketu - tugi
    A_d.append(new)
    print(sum(list(map(abs, A_d))))
    print(ketu, tugi)
    while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new) (A_d[0] <= 0 and A_d[n-1] > 0) or (A_d[0] < 0 and A_d[n-1] >= 0) A_d[0] <= 0 and A_d[n-1] > 0 A_d[0] <= 0 A_d[0] A_d 0 0 A_d[n-1] > 0 A_d[n-1] A_d n-1 n 1 0 A_d[0] < 0 and A_d[n-1] >= 0 A_d[0] < 0 A_d[0] A_d 0 0 A_d[n-1] >= 0 A_d[n-1] A_d n-1 n 1 0 print(sum(list(map(abs, A_d)))) print sum(list(map(abs, A_d))) sum list(map(abs, A_d)) list map(abs, A_d) map abs A_d while A_d[-2] >= 0:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
     A_d[-2] >= 0 A_d[-2] A_d -2 0 atama = A_d.popleft() atama A_d.popleft() A_d.popleft A_d popleft ketu = A_d.pop() ketu A_d.pop() A_d.pop A_d pop print(atama, ketu) print atama ketu new = atama - ketu new atama - ketu atama ketu A_d.appendleft(new) A_d.appendleft A_d appendleft new while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new) len(A_d) != 1 len(A_d) len A_d 1 atama = A_d.popleft() atama A_d.popleft() A_d.popleft A_d popleft ketu = A_d.pop() ketu A_d.pop() A_d.pop A_d pop print(ketu, atama) print ketu atama new = ketu - atama new ketu - atama ketu atama A_d.append(new) A_d.append A_d append new elif A_d[0] > 0:
    atama = A_d.popleft()
    tugi = A_d.popleft()
    new = atama - tugi
    A_d.appendleft(new)
    print(sum(list(map(abs, A_d))))
    print(atama, tugi)
    while len(A_d) != 2:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    atama = A_d.popleft()
    ketu = A_d.pop()
    print(ketu, atama) A_d[0] > 0 A_d[0] A_d 0 0 atama = A_d.popleft() atama A_d.popleft() A_d.popleft A_d popleft tugi = A_d.popleft() tugi A_d.popleft() A_d.popleft A_d popleft new = atama - tugi new atama - tugi atama tugi A_d.appendleft(new) A_d.appendleft A_d appendleft new print(sum(list(map(abs, A_d)))) print sum(list(map(abs, A_d))) sum list(map(abs, A_d)) list map(abs, A_d) map abs A_d print(atama, tugi) print atama tugi while len(A_d) != 2:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
     len(A_d) != 2 len(A_d) len A_d 2 atama = A_d.popleft() atama A_d.popleft() A_d.popleft A_d popleft ketu = A_d.pop() ketu A_d.pop() A_d.pop A_d pop print(atama, ketu) print atama ketu new = atama - ketu new atama - ketu atama ketu A_d.appendleft(new) A_d.appendleft A_d appendleft new atama = A_d.popleft() atama A_d.popleft() A_d.popleft A_d popleft ketu = A_d.pop() ketu A_d.pop() A_d.pop A_d pop print(ketu, atama) print ketu atama ketu = A_d.pop() ketu A_d.pop() A_d.pop A_d pop tugi = A_d.pop() tugi A_d.pop() A_d.pop A_d pop new = ketu - tugi new ketu - tugi ketu tugi A_d.append(new) A_d.append A_d append new print(sum(list(map(abs, A_d)))) print sum(list(map(abs, A_d))) sum list(map(abs, A_d)) list map(abs, A_d) map abs A_d print(ketu, tugi) print ketu tugi while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new) len(A_d) != 1 len(A_d) len A_d 1 atama = A_d.popleft() atama A_d.popleft() A_d.popleft A_d popleft ketu = A_d.pop() ketu A_d.pop() A_d.pop A_d pop print(ketu, atama) print ketu atama new = ketu - atama new ketu - atama ketu atama A_d.append(new) A_d.append A_d append new new = atama - ketu atama - ketu new atama = A_d.popleft() A_d.popleft() atama new = ketu - atama ketu - atama new ketu = A_d.pop() A_d.pop() ketu ketu = A_d.pop() A_d.pop() ketu new = atama - ketu atama - ketu new new = ketu - tugi ketu - tugi new tugi = A_d.popleft() A_d.popleft() tugi tugi = A_d.pop() A_d.pop() tugi atama = A_d.popleft() A_d.popleft() atama A_d = deque(A) deque(A) A_d ketu = A_d.pop() A_d.pop() ketu atama = A_d.popleft() A_d.popleft() atama ketu = A_d.pop() A_d.pop() ketu new = atama - tugi atama - tugi new ketu = A_d.pop() A_d.pop() ketu ketu = A_d.pop() A_d.pop() ketu atama = A_d.popleft() A_d.popleft() atama atama = A_d.popleft() A_d.popleft() atama n = int(input()) int(input()) n new = ketu - atama ketu - atama new A = list(map(int, input().split())) list(map(int, input().split())) A atama = A_d.popleft() A_d.popleft() atama
from collections import deque

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

A.sort()
A_d = deque(A)

if (A_d[0] <= 0 and A_d[n-1] > 0) or (A_d[0] < 0 and A_d[n-1] >= 0):
    print(sum(list(map(abs, A_d))))
    while A_d[-2] >= 0:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new)
elif A_d[0] > 0:
    atama = A_d.popleft()
    tugi = A_d.popleft()
    new = atama - tugi
    A_d.appendleft(new)
    print(sum(list(map(abs, A_d))))
    print(atama, tugi)
    while len(A_d) != 2:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(atama, ketu)
        new = atama - ketu
        A_d.appendleft(new)
    atama = A_d.popleft()
    ketu = A_d.pop()
    print(ketu, atama)
else:
    ketu = A_d.pop()
    tugi = A_d.pop()
    new = ketu - tugi
    A_d.append(new)
    print(sum(list(map(abs, A_d))))
    print(ketu, tugi)
    while len(A_d) != 1:
        atama = A_d.popleft()
        ketu = A_d.pop()
        print(ketu, atama)
        new = ketu - atama
        A_d.append(new)