import sys
INF = 10 ** 11
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
from heapq import heapify,heappush,heappop   

def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = []
    p = []
    z = 0
    for num in a:
        if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
    ans = []
    
    if z == n:
        print(0)
        for i in range(n - 1):
            print(0,0)
        return

    if len(p) == 0:
        if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
    elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
    elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
    for i in range(z):
        ans.append((num1,0))
    print(num1)
    for i in range(n - 1):
        print(*ans[i])

if __name__=='__main__':
    main() import sys sys INF = 10 ** 11 INF 10 ** 11 10 11 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 from collections import deque sys.setrecursionlimit(100000000) sys.setrecursionlimit sys setrecursionlimit 100000000 from heapq import heapify,heappush,heappop def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = []
    p = []
    z = 0
    for num in a:
        if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
    ans = []
    
    if z == n:
        print(0)
        for i in range(n - 1):
            print(0,0)
        return

    if len(p) == 0:
        if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
    elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
    elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
    for i in range(z):
        ans.append((num1,0))
    print(num1)
    for i in range(n - 1):
        print(*ans[i]) 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 m = [] m [] p = [] p [] z = 0 z 0 for num in a:
        if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
     num a if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
     num < 0 num 0 m.append(num) m.append m append num elif num > 0:
            p.append(num)
         num > 0 num 0 p.append(num) p.append p append num z += 1 z 1 ans = [] ans [] if z == n:
        print(0)
        for i in range(n - 1):
            print(0,0)
        return

     z == n z n print(0) print 0 for i in range(n - 1):
            print(0,0)
         i range(n - 1) range n - 1 n 1 print(0,0) print 0 0 return if len(p) == 0:
        if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
    elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
    elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
     len(p) == 0 len(p) len p 0 if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
         z num1 = 0 num1 0 z -= 1 z 1 m.sort() m.sort m sort num1 = m[-1] num1 m[-1] m -1 m.pop() m.pop m pop for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
     i range(len(m)) range len(m) len m ans.append((num1,m[i])) ans.append ans append (num1,m[i]) num1 m[i] m i num1 -= m[i] num1 m[i] m i elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
     len(m) == 0 len(m) len m 0 if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
         z num1 = 0 num1 0 z -= 1 z 1 idx = 0 idx 0 p.sort() p.sort p sort num1 = p[0] num1 p[0] p 0 idx = 1 idx 1 for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
         i range(idx,len(p) - 1) range idx len(p) - 1 len(p) len p 1 ans.append((num1,p[i])) ans.append ans append (num1,p[i]) num1 p[i] p i num1 -= p[i] num1 p[i] p i ans.append((p[-1],num1)) ans.append ans append (p[-1],num1) p[-1] p -1 num1 num1 = p[-1] - num1 num1 p[-1] - num1 p[-1] p -1 num1 elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
     len(p) * len(m) > 0 len(p) * len(m) len(p) len p len(m) len m 0 num1 = p[-1] num1 p[-1] p -1 p.pop() p.pop p pop num2 = m[-1] num2 m[-1] m -1 m.pop() m.pop m pop for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
         i range(len(m)) range len(m) len m ans.append((num1,m[i])) ans.append ans append (num1,m[i]) num1 m[i] m i num1 -= m[i] num1 m[i] m i for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
         i range(len(p)) range len(p) len p ans.append((num2,p[i])) ans.append ans append (num2,p[i]) num2 p[i] p i num2 -= p[i] num2 p[i] p i ans.append((num1,num2)) ans.append ans append (num1,num2) num1 num2 num1 -= num2 num1 num2 for i in range(z):
        ans.append((num1,0))
     i range(z) range z ans.append((num1,0)) ans.append ans append (num1,0) num1 0 print(num1) print num1 for i in range(n - 1):
        print(*ans[i]) i range(n - 1) range n - 1 n 1 print(*ans[i]) print *ans[i] ans[i] ans i if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main INF = 10 ** 11 10 ** 11 INF def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = []
    p = []
    z = 0
    for num in a:
        if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
    ans = []
    
    if z == n:
        print(0)
        for i in range(n - 1):
            print(0,0)
        return

    if len(p) == 0:
        if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
    elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
    elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
    for i in range(z):
        ans.append((num1,0))
    print(num1)
    for i in range(n - 1):
        print(*ans[i]) def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = []
    p = []
    z = 0
    for num in a:
        if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
    ans = []
    
    if z == n:
        print(0)
        for i in range(n - 1):
            print(0,0)
        return

    if len(p) == 0:
        if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
    elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
    elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
    for i in range(z):
        ans.append((num1,0))
    print(num1)
    for i in range(n - 1):
        print(*ans[i]) main MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys
INF = 10 ** 11
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
from heapq import heapify,heappush,heappop   

def main():
    n = int(input())
    a = list(map(int,input().split()))
    m = []
    p = []
    z = 0
    for num in a:
        if num < 0:
            m.append(num)
        elif num > 0:
            p.append(num)
        else:
            z += 1
    
    ans = []
    
    if z == n:
        print(0)
        for i in range(n - 1):
            print(0,0)
        return

    if len(p) == 0:
        if z:
            num1 = 0
            z -= 1
        else:
            m.sort()
            num1 = m[-1]
            m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
    
    elif len(m) == 0:
        if z:
            num1 = 0
            z -= 1
            idx = 0
        else:
            p.sort()
            num1 = p[0]
            idx = 1
        for i in range(idx,len(p) - 1):
            ans.append((num1,p[i]))
            num1 -= p[i]
        ans.append((p[-1],num1))
        num1 = p[-1] - num1
    
    elif len(p) * len(m) > 0:
        num1 = p[-1]
        p.pop()
        num2 = m[-1]
        m.pop()
        for i in range(len(m)):
            ans.append((num1,m[i]))
            num1 -= m[i]
        for i in range(len(p)):
            ans.append((num2,p[i]))
            num2 -= p[i]
        ans.append((num1,num2))
        num1 -= num2
    
    for i in range(z):
        ans.append((num1,0))
    print(num1)
    for i in range(n - 1):
        print(*ans[i])

if __name__=='__main__':
    main()