#!/usr/bin/env python3

import sys


def main():
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())



    def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
    n = ii()
    L = lmi()
    L.sort(reverse=True)
    M, command = solve(L)
    print(M)
    for x, y in command:
        print(f"{x} {y}")


if __name__ == "__main__":
    main() import sys sys def main():
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())



    def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
    n = ii()
    L = lmi()
    L.sort(reverse=True)
    M, command = solve(L)
    print(M)
    for x, y in command:
        print(f"{x} {y}") main def input(): return sys.stdin.readline().rstrip()
     input def ii():    return int(input())
     ii def isp():   return input().split()
     isp def mi():    return map(int, input().split())
     mi def mi_0():  return map(lambda x: int(x)-1, input().split())
     mi_0 def lmi():   return list(map(int, input().split()))
     lmi def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
     lmi_0 def li():    return list(input())



     li def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
     solve M = 0 M 0 command = [] command [] if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
         L[-1] >= 0 L[-1] L -1 0 if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
         len(L) > 2 len(L) len L 2 command.append([L[-1], L[0]]) command.append command append [L[-1], L[0]] L[-1] L -1 L[0] L 0 neg = L[-1] - L[0] neg L[-1] - L[0] L[-1] L -1 L[0] L 0 L = L[1:-1] L L[1:-1] L 1:-1 1 -1 for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                 i range(1, len(L)) range 1 len(L) len L command.append([neg, L[i]]) command.append command append [neg, L[i]] neg L[i] L i neg -= L[i] neg L[i] L i command.append([L[0], neg]) command.append command append [L[0], neg] L[0] L 0 neg M = L[0] - neg M L[0] - neg L[0] L 0 neg command.append([L[0], L[1]]) command.append command append [L[0], L[1]] L[0] L 0 L[1] L 1 M = L[0] - L[1] M L[0] - L[1] L[0] L 0 L[1] L 1 elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
         L[0] <= 0 L[0] L 0 0 command.append([L[0], L[-1]]) command.append command append [L[0], L[-1]] L[0] L 0 L[-1] L -1 pos = L[0] - L[-1] pos L[0] - L[-1] L[0] L 0 L[-1] L -1 L = L[1:-1] L L[1:-1] L 1:-1 1 -1 for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
             i range(len(L)) range len(L) len L command.append([pos, L[i]]) command.append command append [pos, L[i]] pos L[i] L i pos -= L[i] pos L[i] L i M = pos M pos for i in range(len(L)):
                if L[i] < 0:
                    break
             i range(len(L)) range len(L) len L if L[i] < 0:
                    break
             L[i] < 0 L[i] L i 0 break neg = L[i] neg L[i] L i for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
             j range(1, i) range 1 i command.append([neg, L[j]]) command.append command append [neg, L[j]] neg L[j] L j neg -= L[j] neg L[j] L j L = [L[0], neg] + L[i+1:] L [L[0], neg] + L[i+1:] [L[0], neg] L[0] L 0 neg L[i+1:] L i+1: i+1 i 1 M = L[0] M L[0] L 0 for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
         i range(1, len(L)) range 1 len(L) len L command.append([M, L[i]]) command.append command append [M, L[i]] M L[i] L i M -= L[i] M L[i] L i return M, command return M, command M command L L n = ii() n ii() ii L = lmi() L lmi() lmi L.sort(reverse=True) L.sort L sort reverse=True reverse True M, command = solve(L) M solve(L) solve L command print(M) print M for x, y in command:
        print(f"{x} {y}") x y command print(f"{x} {y}") print f"{x} {y}" if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())



    def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
    n = ii()
    L = lmi()
    L.sort(reverse=True)
    M, command = solve(L)
    print(M)
    for x, y in command:
        print(f"{x} {y}") def main():
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())



    def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
    n = ii()
    L = lmi()
    L.sort(reverse=True)
    M, command = solve(L)
    print(M)
    for x, y in command:
        print(f"{x} {y}") main
#!/usr/bin/env python3

import sys


def main():
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())



    def solve(L):
        M = 0
        command = []
        if L[-1] >= 0:
            # 全て正
            if len(L) > 2:
                command.append([L[-1], L[0]])
                neg = L[-1] - L[0]
                L = L[1:-1]
                for i in range(1, len(L)):
                    command.append([neg, L[i]])
                    neg -= L[i]
                # 最後に正 - 負
                command.append([L[0], neg])
                M = L[0] - neg
            else:
                command.append([L[0], L[1]])
                M = L[0] - L[1]
        elif L[0] <= 0:
            # 全て負
            command.append([L[0], L[-1]])
            pos = L[0] - L[-1]            
            L = L[1:-1]
            for i in range(len(L)):
                command.append([pos, L[i]])
                pos -= L[i]
            M = pos
        else:
            for i in range(len(L)):
                if L[i] < 0:
                    break
            neg = L[i]
            for j in range(1, i):
                command.append([neg, L[j]])
                neg -= L[j]
            L = [L[0], neg] + L[i+1:]
            M = L[0]
            for i in range(1, len(L)):
                command.append([M, L[i]])
                M -= L[i]
        return M, command
                

    
    
    n = ii()
    L = lmi()
    L.sort(reverse=True)
    M, command = solve(L)
    print(M)
    for x, y in command:
        print(f"{x} {y}")


if __name__ == "__main__":
    main()
