from collections import deque
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s)

if __name__ == "__main__":
    main() from collections import deque import bisect bisect def main():
    N = int(input())
    A = list(map(int, input().split()))

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s) 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 plus = [] plus [] minus = [] minus [] for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
     a A if a >= 0:
            plus.append(a)
         a >= 0 a 0 plus.append(a) plus.append plus append a if a < 0:
            minus.append(a)
        
     a < 0 a 0 minus.append(a) minus.append minus append a plus.sort() plus.sort plus sort minus.sort() minus.sort minus sort plus = deque(plus) plus deque(plus) deque plus minus = deque(minus) minus deque(minus) deque minus if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

     N == 2 N 2 if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
         A[0] >= A[1] A[0] A 0 A[1] A 1 ans = A[0] - A[1] ans A[0] - A[1] A[0] A 0 A[1] A 1 print(ans) print ans print(A[0], A[1]) print A[0] A 0 A[1] A 1 ans = A[1] - A[0] ans A[1] - A[0] A[1] A 1 A[0] A 0 print(ans) print ans print(A[1], A[0]) print A[1] A 1 A[0] A 0 return anslist = [] anslist [] if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

     len(plus) == 0 len(plus) len plus 0 stmp = minus.popleft() stmp minus.popleft() minus.popleft minus popleft ltmp = minus.pop() ltmp minus.pop() minus.pop minus pop anslist.append((ltmp, stmp)) anslist.append anslist append (ltmp, stmp) ltmp stmp ans = ltmp - stmp ans ltmp - stmp ltmp stmp plus.append(ans) plus.append plus append ans N -= 1 N 1 elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
     len(minus) == 0 len(minus) len minus 0 stmp = plus.popleft() stmp plus.popleft() plus.popleft plus popleft ltmp = plus.pop() ltmp plus.pop() plus.pop plus pop anslist.append((stmp, ltmp)) anslist.append anslist append (stmp, ltmp) stmp ltmp ans = stmp - ltmp ans stmp - ltmp stmp ltmp minus.append(ans) minus.append minus append ans N -= 1 N 1 for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
     _ range(N) range N if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
     len(minus) > 1 len(minus) len minus 1 ltmp = plus.pop() ltmp plus.pop() plus.pop plus pop stmp = minus.pop() stmp minus.pop() minus.pop minus pop anslist.append((ltmp, stmp)) anslist.append anslist append (ltmp, stmp) ltmp stmp plus.append(ltmp - stmp) plus.append plus append ltmp - stmp ltmp stmp elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
         len(plus) > 1 len(plus) len plus 1 ltmp = plus.popleft() ltmp plus.popleft() plus.popleft plus popleft stmp = minus.popleft() stmp minus.popleft() minus.popleft minus popleft anslist.append((stmp, ltmp)) anslist.append anslist append (stmp, ltmp) stmp ltmp minus.append(stmp - ltmp) minus.append minus append stmp - ltmp stmp ltmp ltmp = plus.popleft() ltmp plus.popleft() plus.popleft plus popleft stmp = minus.popleft() stmp minus.popleft() minus.popleft minus popleft anslist.append((ltmp, stmp)) anslist.append anslist append (ltmp, stmp) ltmp stmp ans = ltmp - stmp ans ltmp - stmp ltmp stmp break print(ans) print ans for s in anslist:
        print(*s) s anslist print(*s) print *s s if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    A = list(map(int, input().split()))

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s) def main():
    N = int(input())
    A = list(map(int, input().split()))

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s) main
from collections import deque
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    plus = []; minus = []
    for a in A:
        if a >= 0:
            plus.append(a)
        if a < 0:
            minus.append(a)
        
    plus.sort()
    minus.sort()
    plus = deque(plus)
    minus = deque(minus)

    if N == 2:
        if A[0] >= A[1]:
            ans = A[0] - A[1]
            print(ans)
            print(A[0], A[1])
        else:
            ans = A[1] - A[0]
            print(ans)
            print(A[1], A[0])
        return

    anslist = []
    if len(plus) == 0:
        stmp = minus.popleft()
        ltmp = minus.pop()
        anslist.append((ltmp, stmp))
        ans = ltmp - stmp
        plus.append(ans)
        N -= 1
    elif len(minus) == 0:
        stmp = plus.popleft()
        ltmp = plus.pop()
        anslist.append((stmp, ltmp))
        ans = stmp - ltmp
        minus.append(ans)
        N -= 1
    else:
        pass

    for _ in range(N):
        if len(minus) > 1:
            ltmp = plus.pop()
            stmp = minus.pop()
            anslist.append((ltmp, stmp))
            plus.append(ltmp - stmp)
        elif len(plus) > 1:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((stmp, ltmp))
            minus.append(stmp - ltmp)
        else:
            ltmp = plus.popleft()
            stmp = minus.popleft()
            anslist.append((ltmp, stmp))
            ans = ltmp - stmp
            break
    print(ans)
    for s in anslist:
        print(*s)

if __name__ == "__main__":
    main()
