import sys
import copy
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    if A[0] >= 0:
        ans = sum(A[1:]) - A[0]
        plus = copy.deepcopy(A[1:])
        minus = [A[0]]
    elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
    else:
        plus = []
        minus = []
        ans = 0
        for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

    plus = deque(plus)
    minus = deque(minus)
    print(ans)

    # minusをまず一つにする
    while len(minus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(p, m)
        plus.append(p - m)

    # minusが1つになったあとの処理
    p = plus.pop()
    m = minus.pop()
    if len(plus) == 0:
        print(p, m)
        return

    print(m, p)
    cur = m - p
    while len(plus) > 1:
        p = plus.pop()
        print(cur, p)
        cur -= p
    if len(plus) != 0:
        p = plus.pop()
        print(p, cur)


if __name__ == "__main__":
    main() import sys sys import copy copy from collections import deque sys.setrecursionlimit(10 ** 6) sys.setrecursionlimit sys setrecursionlimit 10 ** 6 10 6 INF = float("inf") INF float("inf") float "inf" MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def input():
    return sys.stdin.readline().strip() input return sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    if A[0] >= 0:
        ans = sum(A[1:]) - A[0]
        plus = copy.deepcopy(A[1:])
        minus = [A[0]]
    elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
    else:
        plus = []
        minus = []
        ans = 0
        for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

    plus = deque(plus)
    minus = deque(minus)
    print(ans)

    # minusをまず一つにする
    while len(minus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(p, m)
        plus.append(p - m)

    # minusが1つになったあとの処理
    p = plus.pop()
    m = minus.pop()
    if len(plus) == 0:
        print(p, m)
        return

    print(m, p)
    cur = m - p
    while len(plus) > 1:
        p = plus.pop()
        print(cur, p)
        cur -= p
    if len(plus) != 0:
        p = plus.pop()
        print(p, cur) 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 if A[0] >= 0:
        ans = sum(A[1:]) - A[0]
        plus = copy.deepcopy(A[1:])
        minus = [A[0]]
    elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
    else:
        plus = []
        minus = []
        ans = 0
        for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

     A[0] >= 0 A[0] A 0 0 ans = sum(A[1:]) - A[0] ans sum(A[1:]) - A[0] sum(A[1:]) sum A[1:] A 1: 1 A[0] A 0 plus = copy.deepcopy(A[1:]) plus copy.deepcopy(A[1:]) copy.deepcopy copy deepcopy A[1:] A 1: 1 minus = [A[0]] minus [A[0]] A[0] A 0 elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
     A[-1] <= 0 A[-1] A -1 0 ans = -sum(A[:-1]) + A[-1] ans -sum(A[:-1]) + A[-1] -sum(A[:-1]) sum(A[:-1]) sum A[:-1] A :-1 -1 A[-1] A -1 plus = [A[-1]] plus [A[-1]] A[-1] A -1 minus = copy.deepcopy(A[:-1]) minus copy.deepcopy(A[:-1]) copy.deepcopy copy deepcopy A[:-1] A :-1 -1 plus = [] plus [] minus = [] minus [] ans = 0 ans 0 for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

     a A if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

     a >= 0 a 0 ans += a ans a plus.append(a) plus.append plus append a ans -= a ans a minus.append(a) minus.append minus append a plus = deque(plus) plus deque(plus) deque plus minus = deque(minus) minus deque(minus) deque minus print(ans) print ans while len(minus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(p, m)
        plus.append(p - m)

    # minusが1つになったあとの処理
     len(minus) > 1 len(minus) len minus 1 p = plus.pop() p plus.pop() plus.pop plus pop m = minus.pop() m minus.pop() minus.pop minus pop print(p, m) print p m plus.append(p - m) plus.append plus append p - m p m p = plus.pop() p plus.pop() plus.pop plus pop m = minus.pop() m minus.pop() minus.pop minus pop if len(plus) == 0:
        print(p, m)
        return

     len(plus) == 0 len(plus) len plus 0 print(p, m) print p m return print(m, p) print m p cur = m - p cur m - p m p while len(plus) > 1:
        p = plus.pop()
        print(cur, p)
        cur -= p
     len(plus) > 1 len(plus) len plus 1 p = plus.pop() p plus.pop() plus.pop plus pop print(cur, p) print cur p cur -= p cur p if len(plus) != 0:
        p = plus.pop()
        print(p, cur) len(plus) != 0 len(plus) len plus 0 p = plus.pop() p plus.pop() plus.pop plus pop print(p, cur) print p cur if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main INF = float("inf") float("inf") INF def input():
    return sys.stdin.readline().strip() def input():
    return sys.stdin.readline().strip() input def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    if A[0] >= 0:
        ans = sum(A[1:]) - A[0]
        plus = copy.deepcopy(A[1:])
        minus = [A[0]]
    elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
    else:
        plus = []
        minus = []
        ans = 0
        for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

    plus = deque(plus)
    minus = deque(minus)
    print(ans)

    # minusをまず一つにする
    while len(minus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(p, m)
        plus.append(p - m)

    # minusが1つになったあとの処理
    p = plus.pop()
    m = minus.pop()
    if len(plus) == 0:
        print(p, m)
        return

    print(m, p)
    cur = m - p
    while len(plus) > 1:
        p = plus.pop()
        print(cur, p)
        cur -= p
    if len(plus) != 0:
        p = plus.pop()
        print(p, cur) def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    if A[0] >= 0:
        ans = sum(A[1:]) - A[0]
        plus = copy.deepcopy(A[1:])
        minus = [A[0]]
    elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
    else:
        plus = []
        minus = []
        ans = 0
        for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

    plus = deque(plus)
    minus = deque(minus)
    print(ans)

    # minusをまず一つにする
    while len(minus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(p, m)
        plus.append(p - m)

    # minusが1つになったあとの処理
    p = plus.pop()
    m = minus.pop()
    if len(plus) == 0:
        print(p, m)
        return

    print(m, p)
    cur = m - p
    while len(plus) > 1:
        p = plus.pop()
        print(cur, p)
        cur -= p
    if len(plus) != 0:
        p = plus.pop()
        print(p, cur) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys
import copy
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()

    if A[0] >= 0:
        ans = sum(A[1:]) - A[0]
        plus = copy.deepcopy(A[1:])
        minus = [A[0]]
    elif A[-1] <= 0:
        ans = -sum(A[:-1]) + A[-1]
        plus = [A[-1]]
        minus = copy.deepcopy(A[:-1])
    else:
        plus = []
        minus = []
        ans = 0
        for a in A:
            if a >= 0:
                ans += a
                plus.append(a)
            else:
                ans -= a
                minus.append(a)

    plus = deque(plus)
    minus = deque(minus)
    print(ans)

    # minusをまず一つにする
    while len(minus) > 1:
        p = plus.pop()
        m = minus.pop()
        print(p, m)
        plus.append(p - m)

    # minusが1つになったあとの処理
    p = plus.pop()
    m = minus.pop()
    if len(plus) == 0:
        print(p, m)
        return

    print(m, p)
    cur = m - p
    while len(plus) > 1:
        p = plus.pop()
        print(cur, p)
        cur -= p
    if len(plus) != 0:
        p = plus.pop()
        print(p, cur)


if __name__ == "__main__":
    main()
