def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                

if __name__ == "__main__":
    main() def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 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 all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 all([a > 0 for a in A]) all [a > 0 for a in A] pre = A[0] pre A[0] A 0 M = sum(A) - 2 * min(A) M sum(A) - 2 * min(A) sum(A) sum A 2 * min(A) 2 min(A) min A print(M) print M for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
     i range(1,N) range 1 N if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
     i != N - 1 i N - 1 N 1 print(pre, A[i]) print pre A[i] A i pre -= A[i] pre A[i] A i print(A[i], pre) print A[i] A i pre elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
     all([a < 0 for a in A]) all [a < 0 for a in A] M = A[-1] M A[-1] A -1 for i in range(N-1):
            M -= A[i]
         i range(N-1) range N-1 N 1 M -= A[i] M A[i] A i print(M) print M pre = A[-1] pre A[-1] A -1 for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
     i range(N-1) range N-1 N 1 print(pre, A[i]) print pre A[i] A i pre -= A[i] pre A[i] A i cnt = 0 cnt 0 M = 0 M 0 for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
         a A if a > 0:
                cnt += 1
             a > 0 a 0 cnt += 1 cnt 1 M += abs(a) M abs(a) abs a print(M) print M if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 cnt == 1 cnt 1 pre = A[-1] pre A[-1] A -1 for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
         i range(N-1) range N-1 N 1 print(pre, A[i]) print pre A[i] A i pre -= A[i] pre A[i] A i pre = A[0] pre A[0] A 0 for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

             i range(1,N-1) range 1 N-1 N 1 if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

             A[i] >= 0 A[i] A i 0 print(pre, A[i]) print pre A[i] A i pre -= A[i] pre A[i] A i print(A[-1],pre) print A[-1] A -1 pre pre = A[-1] - pre pre A[-1] - pre A[-1] A -1 pre for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 i range(1,N-1) range 1 N-1 N 1 if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 A[i] < 0 A[i] A i 0 print(pre, A[i]) print pre A[i] A i pre -= A[i] pre A[i] A i break if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                 main
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    if all([a > 0 for a in A]):
        pre = A[0]
        M = sum(A) - 2 * min(A)
        print(M)
        for i in range(1,N):
            if i != N - 1:
                print(pre, A[i])
                pre -= A[i]
            else:
                print(A[i], pre)
    elif all([a < 0 for a in A]):
        M = A[-1]
        for i in range(N-1):
            M -= A[i]
        print(M)
        pre = A[-1]
        for i in range(N-1):
            print(pre, A[i])
            pre -= A[i]
    else:
        cnt = 0
        M = 0
        for a in A:
            if a > 0:
                cnt += 1
            M += abs(a)
        print(M)
        if cnt == 1:
            pre = A[-1]
            for i in range(N-1):
                print(pre, A[i])
                pre -= A[i]
        else:
            pre = A[0]
            for i in range(1,N-1):
                if A[i] >= 0:
                    print(pre, A[i])
                    pre -= A[i]

            print(A[-1],pre)
            pre = A[-1] - pre
            for i in range(1,N-1):
                if A[i] < 0:
                    print(pre, A[i])
                    pre -= A[i]
                else:
                    break
                

if __name__ == "__main__":
    main()