import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    A.sort()
    
    ope = [[] for _ in range(N - 1)]
    for i in range(N - 2):
        if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
    ope[N - 2] = [A[-1], A[0]]
    
    ans = A[-1] - A[0]
    print(ans)
    for x, y in ope:
        print(x, y)


if __name__ == '__main__':
    solve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 rl = sys.stdin.readline rl sys.stdin.readline sys.stdin sys stdin readline def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    A.sort()
    
    ope = [[] for _ in range(N - 1)]
    for i in range(N - 2):
        if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
    ope[N - 2] = [A[-1], A[0]]
    
    ans = A[-1] - A[0]
    print(ans)
    for x, y in ope:
        print(x, y) solve N = int(rl()) N int(rl()) int rl() rl A = list(map(int, rl().split())) A list(map(int, rl().split())) list map(int, rl().split()) map int rl().split() ().split () rl split A.sort() A.sort A sort [] for _ in range(N - 1) for _ in range(N - 1) _ range(N - 1) range N - 1 N 1 for _ in range(N - 1) [] ope = [[] for _ in range(N - 1)] ope [[] for _ in range(N - 1)] for i in range(N - 2):
        if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
     i range(N - 2) range N - 2 N 2 if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
     0 <= A[i + 1] 0 A[i + 1] A i + 1 i 1 ope[i] = [A[0], A[i + 1]] ope[i] ope i [A[0], A[i + 1]] A[0] A 0 A[i + 1] A i + 1 i 1 A[0] -= A[i + 1] A[0] A 0 A[i + 1] A i + 1 i 1 ope[i] = [A[-1], A[i + 1]] ope[i] ope i [A[-1], A[i + 1]] A[-1] A -1 A[i + 1] A i + 1 i 1 A[-1] -= A[i + 1] A[-1] A -1 A[i + 1] A i + 1 i 1 ope[N - 2] = [A[-1], A[0]] ope[N - 2] ope N - 2 N 2 [A[-1], A[0]] A[-1] A -1 A[0] A 0 ans = A[-1] - A[0] ans A[-1] - A[0] A[-1] A -1 A[0] A 0 print(ans) print ans for x, y in ope:
        print(x, y) x y ope print(x, y) print x y if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve rl = sys.stdin.readline sys.stdin.readline rl def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    A.sort()
    
    ope = [[] for _ in range(N - 1)]
    for i in range(N - 2):
        if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
    ope[N - 2] = [A[-1], A[0]]
    
    ans = A[-1] - A[0]
    print(ans)
    for x, y in ope:
        print(x, y) def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    A.sort()
    
    ope = [[] for _ in range(N - 1)]
    for i in range(N - 2):
        if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
    ope[N - 2] = [A[-1], A[0]]
    
    ans = A[-1] - A[0]
    print(ans)
    for x, y in ope:
        print(x, y) solve
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    A.sort()
    
    ope = [[] for _ in range(N - 1)]
    for i in range(N - 2):
        if 0 <= A[i + 1]:
            ope[i] = [A[0], A[i + 1]]
            A[0] -= A[i + 1]
        else:
            ope[i] = [A[-1], A[i + 1]]
            A[-1] -= A[i + 1]
    ope[N - 2] = [A[-1], A[0]]
    
    ans = A[-1] - A[0]
    print(ans)
    for x, y in ope:
        print(x, y)


if __name__ == '__main__':
    solve()
