import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    cur = max(a)
    a = a[:n - 1]

    neg = []
    pos = []

    for x in a:
        if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

    seq = []

    if pos:
        pos_que = deque()
        pos_que.extend(pos)
        if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
        while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
        seq.append([cur, cur2])
        cur -= cur2

    for y in neg:
        seq.append([cur, y])
        cur = cur - y

    print(cur)
    for i in range(n - 1):
        print(*seq[i])


if __name__ == '__main__':
    main() import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 INF = float('INF') INF float('INF') float 'INF' sys.setrecursionlimit(10 ** 5) sys.setrecursionlimit sys setrecursionlimit 10 ** 5 10 5 def main():
    from collections import deque

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    cur = max(a)
    a = a[:n - 1]

    neg = []
    pos = []

    for x in a:
        if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

    seq = []

    if pos:
        pos_que = deque()
        pos_que.extend(pos)
        if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
        while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
        seq.append([cur, cur2])
        cur -= cur2

    for y in neg:
        seq.append([cur, y])
        cur = cur - y

    print(cur)
    for i in range(n - 1):
        print(*seq[i]) main from collections import deque n = int(readline()) n int(readline()) int readline() readline a = list(map(int, readline().split())) a list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split a.sort() a.sort a sort cur = max(a) cur max(a) max a a = a[:n - 1] a a[:n - 1] a :n - 1 n - 1 n 1 neg = [] neg [] pos = [] pos [] for x in a:
        if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

     x a if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

     x <= 0 x 0 neg.append(x) neg.append neg append x pos.append(x) pos.append pos append x seq = [] seq [] if pos:
        pos_que = deque()
        pos_que.extend(pos)
        if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
        while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
        seq.append([cur, cur2])
        cur -= cur2

     pos pos_que = deque() pos_que deque() deque pos_que.extend(pos) pos_que.extend pos_que extend pos if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
         neg cur2 = neg.pop() cur2 neg.pop() neg.pop neg pop cur2 = pos_que.popleft() cur2 pos_que.popleft() pos_que.popleft pos_que popleft while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
         pos_que y = pos_que.popleft() y pos_que.popleft() pos_que.popleft pos_que popleft seq.append([cur2, y]) seq.append seq append [cur2, y] cur2 y cur2 = cur2 - y cur2 cur2 - y cur2 y seq.append([cur, cur2]) seq.append seq append [cur, cur2] cur cur2 cur -= cur2 cur cur2 for y in neg:
        seq.append([cur, y])
        cur = cur - y

     y neg seq.append([cur, y]) seq.append seq append [cur, y] cur y cur = cur - y cur cur - y cur y print(cur) print cur for i in range(n - 1):
        print(*seq[i]) i range(n - 1) range n - 1 n 1 print(*seq[i]) print *seq[i] seq[i] seq i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main readline = sys.stdin.readline sys.stdin.readline readline INF = float('INF') float('INF') INF def main():
    from collections import deque

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    cur = max(a)
    a = a[:n - 1]

    neg = []
    pos = []

    for x in a:
        if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

    seq = []

    if pos:
        pos_que = deque()
        pos_que.extend(pos)
        if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
        while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
        seq.append([cur, cur2])
        cur -= cur2

    for y in neg:
        seq.append([cur, y])
        cur = cur - y

    print(cur)
    for i in range(n - 1):
        print(*seq[i]) def main():
    from collections import deque

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    cur = max(a)
    a = a[:n - 1]

    neg = []
    pos = []

    for x in a:
        if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

    seq = []

    if pos:
        pos_que = deque()
        pos_que.extend(pos)
        if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
        while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
        seq.append([cur, cur2])
        cur -= cur2

    for y in neg:
        seq.append([cur, y])
        cur = cur - y

    print(cur)
    for i in range(n - 1):
        print(*seq[i]) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    cur = max(a)
    a = a[:n - 1]

    neg = []
    pos = []

    for x in a:
        if x <= 0:
            neg.append(x)
        else:
            pos.append(x)

    seq = []

    if pos:
        pos_que = deque()
        pos_que.extend(pos)
        if neg:
            cur2 = neg.pop()
        else:
            cur2 = pos_que.popleft()
        while pos_que:
            y = pos_que.popleft()
            seq.append([cur2, y])
            cur2 = cur2 - y
        seq.append([cur, cur2])
        cur -= cur2

    for y in neg:
        seq.append([cur, y])
        cur = cur - y

    print(cur)
    for i in range(n - 1):
        print(*seq[i])


if __name__ == '__main__':
    main()
