import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**5
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    A.sort(reverse=True)
    p = []
    for i in range(1,len(A)-1):
        if A[i] < 0: break
        p.append((A[-1],A[i]))
        A[-1] -= A[i]
        A[i] = INF
    for a in A[1:]:
        if a < INF:
            p.append((A[0],a))
            A[0] -= a
    print(A[0])
    for a in p:
        print(a[0],a[1])


if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    sys.setrecursionlimit(10**7)
    INF = 10**5
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    A.sort(reverse=True)
    p = []
    for i in range(1,len(A)-1):
        if A[i] < 0: break
        p.append((A[-1],A[i]))
        A[-1] -= A[i]
        A[i] = INF
    for a in A[1:]:
        if a < INF:
            p.append((A[0],a))
            A[0] -= a
    print(A[0])
    for a in p:
        print(a[0],a[1]) main sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**5 INF 10**5 10 5 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline SI = lambda : sys.stdin.readline().rstrip() SI lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip N = NI() N NI() NI A = LI() A LI() LI A.sort(reverse=True) A.sort A sort reverse=True reverse True p = [] p [] for i in range(1,len(A)-1):
        if A[i] < 0: break
        p.append((A[-1],A[i]))
        A[-1] -= A[i]
        A[i] = INF
     i range(1,len(A)-1) range 1 len(A)-1 len(A) len A 1 if A[i] < 0: break
         A[i] < 0 A[i] A i 0 p.append((A[-1],A[i])) p.append p append (A[-1],A[i]) A[-1] A -1 A[i] A i A[-1] -= A[i] A[-1] A -1 A[i] A i A[i] = INF A[i] A i INF for a in A[1:]:
        if a < INF:
            p.append((A[0],a))
            A[0] -= a
     a A[1:] A 1: 1 if a < INF:
            p.append((A[0],a))
            A[0] -= a
     a < INF a INF p.append((A[0],a)) p.append p append (A[0],a) A[0] A 0 a A[0] -= a A[0] A 0 a print(A[0]) print A[0] A 0 for a in p:
        print(a[0],a[1]) a p print(a[0],a[1]) print a[0] a 0 a[1] a 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    sys.setrecursionlimit(10**7)
    INF = 10**5
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    A.sort(reverse=True)
    p = []
    for i in range(1,len(A)-1):
        if A[i] < 0: break
        p.append((A[-1],A[i]))
        A[-1] -= A[i]
        A[i] = INF
    for a in A[1:]:
        if a < INF:
            p.append((A[0],a))
            A[0] -= a
    print(A[0])
    for a in p:
        print(a[0],a[1]) def main():
    sys.setrecursionlimit(10**7)
    INF = 10**5
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    A.sort(reverse=True)
    p = []
    for i in range(1,len(A)-1):
        if A[i] < 0: break
        p.append((A[-1],A[i]))
        A[-1] -= A[i]
        A[i] = INF
    for a in A[1:]:
        if a < INF:
            p.append((A[0],a))
            A[0] -= a
    print(A[0])
    for a in p:
        print(a[0],a[1]) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**5
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = LI()
    A.sort(reverse=True)
    p = []
    for i in range(1,len(A)-1):
        if A[i] < 0: break
        p.append((A[-1],A[i]))
        A[-1] -= A[i]
        A[i] = INF
    for a in A[1:]:
        if a < INF:
            p.append((A[0],a))
            A[0] -= a
    print(A[0])
    for a in p:
        print(a[0],a[1])


if __name__ == '__main__':
    main()