def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])
    maxi = max(A)
    mini = min(A)
    plus = [a for a in A[1:-1] if a >= 0]
    minus = [a for a in A[1:-1] if a < 0]
    print(maxi + sum(plus) - sum(minus) - mini)
    for p in plus:
        print(mini, p)
        mini -= p
    print(maxi, mini)
    maxi -= mini
    for m in minus:
        print(maxi, m)
        maxi -= m

if __name__ == '__main__':
    main() def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])
    maxi = max(A)
    mini = min(A)
    plus = [a for a in A[1:-1] if a >= 0]
    minus = [a for a in A[1:-1] if a < 0]
    print(maxi + sum(plus) - sum(minus) - mini)
    for p in plus:
        print(mini, p)
        mini -= p
    print(maxi, mini)
    maxi -= mini
    for m in minus:
        print(maxi, m)
        maxi -= m main import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input int(x) for x in input().strip().split() for x in input().strip().split() x input().strip().split() ().strip().split ().strip() ().strip () input strip split for x in input().strip().split() int(x) int x A = sorted([int(x) for x in input().strip().split()]) A sorted([int(x) for x in input().strip().split()]) sorted [int(x) for x in input().strip().split()] maxi = max(A) maxi max(A) max A mini = min(A) mini min(A) min A a for a in A[1:-1] if a >= 0 for a in A[1:-1] if a >= 0 a A[1:-1] A 1:-1 1 -1 a >= 0 a 0 if a >= 0 a plus = [a for a in A[1:-1] if a >= 0] plus [a for a in A[1:-1] if a >= 0] a for a in A[1:-1] if a < 0 for a in A[1:-1] if a < 0 a A[1:-1] A 1:-1 1 -1 a < 0 a 0 if a < 0 a minus = [a for a in A[1:-1] if a < 0] minus [a for a in A[1:-1] if a < 0] print(maxi + sum(plus) - sum(minus) - mini) print maxi + sum(plus) - sum(minus) - mini maxi + sum(plus) - sum(minus) maxi + sum(plus) maxi sum(plus) sum plus sum(minus) sum minus mini for p in plus:
        print(mini, p)
        mini -= p
     p plus print(mini, p) print mini p mini -= p mini p print(maxi, mini) print maxi mini maxi -= mini maxi mini for m in minus:
        print(maxi, m)
        maxi -= m m minus print(maxi, m) print maxi m maxi -= m maxi m if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])
    maxi = max(A)
    mini = min(A)
    plus = [a for a in A[1:-1] if a >= 0]
    minus = [a for a in A[1:-1] if a < 0]
    print(maxi + sum(plus) - sum(minus) - mini)
    for p in plus:
        print(mini, p)
        mini -= p
    print(maxi, mini)
    maxi -= mini
    for m in minus:
        print(maxi, m)
        maxi -= m def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])
    maxi = max(A)
    mini = min(A)
    plus = [a for a in A[1:-1] if a >= 0]
    minus = [a for a in A[1:-1] if a < 0]
    print(maxi + sum(plus) - sum(minus) - mini)
    for p in plus:
        print(mini, p)
        mini -= p
    print(maxi, mini)
    maxi -= mini
    for m in minus:
        print(maxi, m)
        maxi -= m main
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()])
    maxi = max(A)
    mini = min(A)
    plus = [a for a in A[1:-1] if a >= 0]
    minus = [a for a in A[1:-1] if a < 0]
    print(maxi + sum(plus) - sum(minus) - mini)
    for p in plus:
        print(mini, p)
        mini -= p
    print(maxi, mini)
    maxi -= mini
    for m in minus:
        print(maxi, m)
        maxi -= m

if __name__ == '__main__':
    main()