# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
while len(positives) > 1:
    if positives[0] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y)

x = positives.popleft()

while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y 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 positives = deque(sorted(a)) positives deque(sorted(a)) deque sorted(a) sorted a negatives = deque([positives.popleft()]) negatives deque([positives.popleft()]) deque [positives.popleft()] positives.popleft() positives.popleft positives popleft while len(positives) > 1:
    if positives[0] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M len(positives) > 1 len(positives) len positives 1 if positives[0] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M positives[0] < 0 positives[0] positives 0 0 negatives.append(positives.popleft()) negatives.append negatives append positives.popleft() positives.popleft positives popleft break print(sum(positives) - sum(negatives)) print sum(positives) - sum(negatives) sum(positives) sum positives sum(negatives) sum negatives while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y) len(positives) > 1 len(positives) len positives 1 y = positives.popleft() y positives.popleft() positives.popleft positives popleft x = negatives.pop() x negatives.pop() negatives.pop negatives pop print(x, y) print x y negatives.append(x - y) negatives.append negatives append x - y x y x = positives.popleft() x positives.popleft() positives.popleft positives popleft while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y len(negatives) > 0 len(negatives) len negatives 0 y = negatives.pop() y negatives.pop() negatives.pop negatives pop print(x, y) print x y x = x - y x x - y x y y = positives.popleft() positives.popleft() y y = negatives.pop() negatives.pop() y a = list(map(int, input().split())) list(map(int, input().split())) a n = int(input()) int(input()) n x = x - y x - y x positives = deque(sorted(a)) deque(sorted(a)) positives x = negatives.pop() negatives.pop() x x = positives.popleft() positives.popleft() x negatives = deque([positives.popleft()]) deque([positives.popleft()]) negatives
# -*- coding: utf-8 -*-
from collections import deque

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

positives = deque(sorted(a))
negatives = deque([positives.popleft()])
while len(positives) > 1:
    if positives[0] < 0:
        negatives.append(positives.popleft())
    else:
        break

# print M
print(sum(positives) - sum(negatives))

while len(positives) > 1:
    y = positives.popleft()
    x = negatives.pop()
    print(x, y)
    negatives.append(x - y)

x = positives.popleft()

while len(negatives) > 0:
    y = negatives.pop()
    print(x, y)
    x = x - y