#!/usr/bin/env python3
def main():
    N = int(input())
    A = list(map(int, input().split()))
    pos = []
    neg = []
    for i in range(N):
        if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
    pos.sort()
    neg.sort(reverse=True)
    
    ans = []
    if len(pos) == 0:# 負だけ
        print(-sum(neg)+2*neg[0])
        now = neg[0]
        for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
    elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
    else:
        p = 0
        n = 1
        ans = []
        now = pos[p]
        while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
        p += 1
        now2 = neg[0]
        while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
        ans.append((now,now2))
        print(now-now2)
        for a in ans:
            print(a[0],a[1])

if __name__ == "__main__":
    main() def main():
    N = int(input())
    A = list(map(int, input().split()))
    pos = []
    neg = []
    for i in range(N):
        if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
    pos.sort()
    neg.sort(reverse=True)
    
    ans = []
    if len(pos) == 0:# 負だけ
        print(-sum(neg)+2*neg[0])
        now = neg[0]
        for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
    elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
    else:
        p = 0
        n = 1
        ans = []
        now = pos[p]
        while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
        p += 1
        now2 = neg[0]
        while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
        ans.append((now,now2))
        print(now-now2)
        for a in ans:
            print(a[0],a[1]) 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 pos = [] pos [] neg = [] neg [] for i in range(N):
        if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
     i range(N) range N if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
     A[i] >= 0 A[i] A i 0 pos.append(A[i]) pos.append pos append A[i] A i neg.append(A[i]) neg.append neg append A[i] A i pos.sort() pos.sort pos sort neg.sort(reverse=True) neg.sort neg sort reverse=True reverse True ans = [] ans [] if len(pos) == 0:# 負だけ
        print(-sum(neg)+2*neg[0])
        now = neg[0]
        for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
    elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
    else:
        p = 0
        n = 1
        ans = []
        now = pos[p]
        while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
        p += 1
        now2 = neg[0]
        while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
        ans.append((now,now2))
        print(now-now2)
        for a in ans:
            print(a[0],a[1]) len(pos) == 0 len(pos) len pos 0 print(-sum(neg)+2*neg[0]) print -sum(neg)+2*neg[0] -sum(neg) sum(neg) sum neg 2*neg[0] 2 neg[0] neg 0 now = neg[0] now neg[0] neg 0 for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
     i range(1,N) range 1 N print(now,neg[i]) print now neg[i] neg i now -= neg[i] now neg[i] neg i elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
     len(neg) == 0 len(neg) len neg 0 print(sum(pos)-2*pos[0]) print sum(pos)-2*pos[0] sum(pos) sum pos 2*pos[0] 2 pos[0] pos 0 now = pos[0] now pos[0] pos 0 for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
         i range(1,N-1) range 1 N-1 N 1 print(now,pos[i]) print now pos[i] pos i now -= pos[i] now pos[i] pos i print(pos[N-1],now) print pos[N-1] pos N-1 N 1 now p = 0 p 0 n = 1 n 1 ans = [] ans [] now = pos[p] now pos[p] pos p while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
         n < len(neg) n len(neg) len neg ans.append((now,neg[n])) ans.append ans append (now,neg[n]) now neg[n] neg n now -= neg[n] now neg[n] neg n n += 1 n 1 p += 1 p 1 now2 = neg[0] now2 neg[0] neg 0 while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
         p < len(pos) p len(pos) len pos ans.append((now2,pos[p])) ans.append ans append (now2,pos[p]) now2 pos[p] pos p now2 -= pos[p] now2 pos[p] pos p p += 1 p 1 ans.append((now,now2)) ans.append ans append (now,now2) now now2 print(now-now2) print now-now2 now now2 for a in ans:
            print(a[0],a[1]) a ans print(a[0],a[1]) print a[0] a 0 a[1] a 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    A = list(map(int, input().split()))
    pos = []
    neg = []
    for i in range(N):
        if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
    pos.sort()
    neg.sort(reverse=True)
    
    ans = []
    if len(pos) == 0:# 負だけ
        print(-sum(neg)+2*neg[0])
        now = neg[0]
        for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
    elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
    else:
        p = 0
        n = 1
        ans = []
        now = pos[p]
        while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
        p += 1
        now2 = neg[0]
        while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
        ans.append((now,now2))
        print(now-now2)
        for a in ans:
            print(a[0],a[1]) def main():
    N = int(input())
    A = list(map(int, input().split()))
    pos = []
    neg = []
    for i in range(N):
        if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
    pos.sort()
    neg.sort(reverse=True)
    
    ans = []
    if len(pos) == 0:# 負だけ
        print(-sum(neg)+2*neg[0])
        now = neg[0]
        for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
    elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
    else:
        p = 0
        n = 1
        ans = []
        now = pos[p]
        while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
        p += 1
        now2 = neg[0]
        while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
        ans.append((now,now2))
        print(now-now2)
        for a in ans:
            print(a[0],a[1]) main
#!/usr/bin/env python3
def main():
    N = int(input())
    A = list(map(int, input().split()))
    pos = []
    neg = []
    for i in range(N):
        if A[i] >= 0:
            pos.append(A[i])
        else:
            neg.append(A[i])
    pos.sort()
    neg.sort(reverse=True)
    
    ans = []
    if len(pos) == 0:# 負だけ
        print(-sum(neg)+2*neg[0])
        now = neg[0]
        for i in range(1,N):
            print(now,neg[i])
            now -= neg[i]
    elif len(neg) == 0:# 正だけ
        print(sum(pos)-2*pos[0])
        now = pos[0]
        for i in range(1,N-1):
            print(now,pos[i])
            now -= pos[i]
        print(pos[N-1],now)
    else:
        p = 0
        n = 1
        ans = []
        now = pos[p]
        while n < len(neg):
            ans.append((now,neg[n]))
            now -= neg[n]
            n += 1
        
        p += 1
        now2 = neg[0]
        while p < len(pos):
            ans.append((now2,pos[p]))
            now2 -= pos[p]
            p += 1
        
        ans.append((now,now2))
        print(now-now2)
        for a in ans:
            print(a[0],a[1])

if __name__ == "__main__":
    main()