#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort()

    if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
    if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
    answer = 0
    plus = []
    minus = []
    for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
    print(answer)
    
    while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
    while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main() import sys sys def solve(N: int, A: "List[int]"):
    A.sort()

    if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
    if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
    answer = 0
    plus = []
    minus = []
    for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
    print(answer)
    
    while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
    while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
    return solve A.sort() A.sort A sort if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
     all([a <= 0 for a in A]) all [a <= 0 for a in A] print(A[-1]-(sum(A)-A[-1])) print A[-1]-(sum(A)-A[-1]) A[-1] A -1 sum(A)-A[-1] sum(A) sum A A[-1] A -1 for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
         i range(N-1) range N-1 N 1 print(A[-1],A[i]) print A[-1] A -1 A[i] A i A[-1] -= A[i] A[-1] A -1 A[i] A i return if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
     all([a >= 0 for a in A]) all [a >= 0 for a in A] print(sum(A)-A[0]-A[0]) print sum(A)-A[0]-A[0] sum(A)-A[0] sum(A) sum A A[0] A 0 A[0] A 0 for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
         i range(1,N-1) range 1 N-1 N 1 print(A[0],A[i]) print A[0] A 0 A[i] A i A[0] -= A[i] A[0] A 0 A[i] A i print(A[-1],A[0]) print A[-1] A -1 A[0] A 0 return answer = 0 answer 0 plus = [] plus [] minus = [] minus [] for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
     i range(N) range N if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
         A[i] >= 0 A[i] A i 0 plus.append(A[i]) plus.append plus append A[i] A i minus.append(A[i]) minus.append minus append A[i] A i answer += abs(A[i]) answer abs(A[i]) abs A[i] A i print(answer) print answer while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
     len(plus)>1 len(plus) len plus 1 p = plus.pop() p plus.pop() plus.pop plus pop m = minus.pop() m minus.pop() minus.pop minus pop minus.append(m-p) minus.append minus append m-p m p print(m,p) print m p while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
     minus m = minus.pop() m minus.pop() minus.pop minus pop print(plus[0],m) print plus[0] plus 0 m plus[0] -= m plus[0] plus 0 m return N: int N A: "List[int]" A def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens N = int(next(tokens)) N int(next(tokens)) int next(tokens) next tokens int(next(tokens)) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(next(tokens)) int next(tokens) next tokens A = [int(next(tokens)) for _ in range(N)] A [int(next(tokens)) for _ in range(N)] solve(N, A) solve N A if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A) main def solve(N: int, A: "List[int]"):
    A.sort()

    if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
    if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
    answer = 0
    plus = []
    minus = []
    for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
    print(answer)
    
    while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
    while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
    return def solve(N: int, A: "List[int]"):
    A.sort()

    if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
    if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
    answer = 0
    plus = []
    minus = []
    for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
    print(answer)
    
    while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
    while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
    return solve
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort()

    if all([a <= 0 for a in A]):
        print(A[-1]-(sum(A)-A[-1]))

        for i in range(N-1):
            print(A[-1],A[i])
            A[-1] -= A[i]
        return
    if all([a >= 0 for a in A]):
        print(sum(A)-A[0]-A[0])
        for i in range(1,N-1):
            print(A[0],A[i])
            A[0] -= A[i]
        print(A[-1],A[0])
        return
    
    answer = 0
    plus = []
    minus = []
    for i in range(N):
        if A[i] >= 0:
            plus.append(A[i])
        else:
            minus.append(A[i])
        answer += abs(A[i])
    print(answer)
    
    while len(plus)>1:
        p = plus.pop()
        m = minus.pop()
        minus.append(m-p)
        print(m,p)
    
    while minus:
        m = minus.pop()
        print(plus[0],m)
        plus[0] -= m
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
