import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    import collections
    D = collections.deque(A)
    ans = []
    for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
    print(D.pop())
    for x, y in ans:
        print(x, y)


if __name__ == '__main__':
    main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    import collections
    D = collections.deque(A)
    ans = []
    for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
    print(D.pop())
    for x, y in ans:
        print(x, y) main 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 import collections collections D = collections.deque(A) D collections.deque(A) collections.deque collections deque A ans = [] ans [] for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
     i range(N-1) range N-1 N 1 a, b = D.popleft(), D.pop() a D.popleft() D.popleft D popleft b D.pop() D.pop D pop if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
     not D or D[-1] < 0 not D D D[-1] < 0 D[-1] D -1 0 D.append(b - a) D.append D append b - a b a ans.append((b, a)) ans.append ans append (b, a) b a D.appendleft(a - b) D.appendleft D appendleft a - b a b ans.append((a, b)) ans.append ans append (a, b) a b print(D.pop()) print D.pop() D.pop D pop for x, y in ans:
        print(x, y) x y ans print(x, y) print x y if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    import collections
    D = collections.deque(A)
    ans = []
    for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
    print(D.pop())
    for x, y in ans:
        print(x, y) def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    import collections
    D = collections.deque(A)
    ans = []
    for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
    print(D.pop())
    for x, y in ans:
        print(x, y) main input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    import collections
    D = collections.deque(A)
    ans = []
    for i in range(N-1):
        a, b = D.popleft(), D.pop()
        if not D or D[-1] < 0:
            D.append(b - a)
            ans.append((b, a))
        else:
            D.appendleft(a - b)
            ans.append((a, b))
    print(D.pop())
    for x, y in ans:
        print(x, y)


if __name__ == '__main__':
    main()
