from collections import deque


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    """
    N = read_int()
    B = read_ints()
    B.sort()
    A = deque(B)
    answer = []
    while len(A) > 1:
        if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
        answer.append((x, y))
    print(A[0])
    for a in answer:
        print(*a)


if __name__ == '__main__':
    solve() from collections import deque def read_int():
    return int(input().strip()) read_int return int(input().strip()) int(input().strip()) int input().strip() ().strip () input strip def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints return list(map(int, input().strip().split(' '))) list(map(int, input().strip().split(' '))) list map(int, input().strip().split(' ')) map int input().strip().split(' ') ().strip().split ().strip() ().strip () input strip split ' ' def solve():
    """
    """
    N = read_int()
    B = read_ints()
    B.sort()
    A = deque(B)
    answer = []
    while len(A) > 1:
        if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
        answer.append((x, y))
    print(A[0])
    for a in answer:
        print(*a) solve """
    """ N = read_int() N read_int() read_int B = read_ints() B read_ints() read_ints B.sort() B.sort B sort A = deque(B) A deque(B) deque B answer = [] answer [] while len(A) > 1:
        if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
        answer.append((x, y))
     len(A) > 1 len(A) len A 1 if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
         len(A) == 2 len(A) len A 2 x, y = A.pop(), A.popleft() x A.pop() A.pop A pop y A.popleft() A.popleft A popleft A.append(x-y) A.append A append x-y x y if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
         A[-2] >= 0 A[-2] A -2 0 x, y = A.popleft(), A.pop() x A.popleft() A.popleft A popleft y A.pop() A.pop A pop A.appendleft(x-y) A.appendleft A appendleft x-y x y x, y = A.pop(), A.popleft() x A.pop() A.pop A pop y A.popleft() A.popleft A popleft A.append(x-y) A.append A append x-y x y answer.append((x, y)) answer.append answer append (x, y) x y print(A[0]) print A[0] A 0 for a in answer:
        print(*a) a answer print(*a) print *a a if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def read_ints():
    return list(map(int, input().strip().split(' '))) def read_ints():
    return list(map(int, input().strip().split(' '))) read_ints def solve():
    """
    """
    N = read_int()
    B = read_ints()
    B.sort()
    A = deque(B)
    answer = []
    while len(A) > 1:
        if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
        answer.append((x, y))
    print(A[0])
    for a in answer:
        print(*a) def solve():
    """
    """
    N = read_int()
    B = read_ints()
    B.sort()
    A = deque(B)
    answer = []
    while len(A) > 1:
        if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
        answer.append((x, y))
    print(A[0])
    for a in answer:
        print(*a) solve def read_int():
    return int(input().strip()) def read_int():
    return int(input().strip()) read_int
from collections import deque


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    """
    N = read_int()
    B = read_ints()
    B.sort()
    A = deque(B)
    answer = []
    while len(A) > 1:
        if len(A) == 2:
            x, y = A.pop(), A.popleft()
            A.append(x-y)
        else:
            if A[-2] >= 0:
                x, y = A.popleft(), A.pop()
                A.appendleft(x-y)
            else:
                x, y = A.pop(), A.popleft()
                A.append(x-y)
        answer.append((x, y))
    print(A[0])
    for a in answer:
        print(*a)


if __name__ == '__main__':
    solve()
