def solve():
    N = int(input())
    A = list(map(int,input().split()))
    neg = []
    pos = []
    for a in A:
        if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
    neg.sort()
    pos.sort()
    
    op = []
    if len(neg) == N:
        pos.append(neg[-1])
        neg.pop()
    
    if len(pos) == N:
        neg.append(pos[0])
        pos = pos[1:]
    
    for i in range(len(pos)-1):
        op.append("{0} {1}".format(neg[0], pos[i]))
        neg[0] -= pos[i]
    
    for ne in neg:
        op.append("{0} {1}".format(pos[-1], ne))
        pos[-1] -= ne
    
    printAns(pos[-1], op)

def printAns(M, op):
    print(M)
    print(*op, sep='\n')
    
if __name__ == '__main__':
    solve() def solve():
    N = int(input())
    A = list(map(int,input().split()))
    neg = []
    pos = []
    for a in A:
        if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
    neg.sort()
    pos.sort()
    
    op = []
    if len(neg) == N:
        pos.append(neg[-1])
        neg.pop()
    
    if len(pos) == N:
        neg.append(pos[0])
        pos = pos[1:]
    
    for i in range(len(pos)-1):
        op.append("{0} {1}".format(neg[0], pos[i]))
        neg[0] -= pos[i]
    
    for ne in neg:
        op.append("{0} {1}".format(pos[-1], ne))
        pos[-1] -= ne
    
    printAns(pos[-1], op) solve 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 neg = [] neg [] pos = [] pos [] for a in A:
        if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
     a A if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
     a < 0 a 0 neg.append(a) neg.append neg append a pos.append(a) pos.append pos append a neg.sort() neg.sort neg sort pos.sort() pos.sort pos sort op = [] op [] if len(neg) == N:
        pos.append(neg[-1])
        neg.pop()
    
     len(neg) == N len(neg) len neg N pos.append(neg[-1]) pos.append pos append neg[-1] neg -1 neg.pop() neg.pop neg pop if len(pos) == N:
        neg.append(pos[0])
        pos = pos[1:]
    
     len(pos) == N len(pos) len pos N neg.append(pos[0]) neg.append neg append pos[0] pos 0 pos = pos[1:] pos pos[1:] pos 1: 1 for i in range(len(pos)-1):
        op.append("{0} {1}".format(neg[0], pos[i]))
        neg[0] -= pos[i]
    
     i range(len(pos)-1) range len(pos)-1 len(pos) len pos 1 op.append("{0} {1}".format(neg[0], pos[i])) op.append op append "{0} {1}".format(neg[0], pos[i]) "{0} {1}".format "{0} {1}" format neg[0] neg 0 pos[i] pos i neg[0] -= pos[i] neg[0] neg 0 pos[i] pos i for ne in neg:
        op.append("{0} {1}".format(pos[-1], ne))
        pos[-1] -= ne
    
     ne neg op.append("{0} {1}".format(pos[-1], ne)) op.append op append "{0} {1}".format(pos[-1], ne) "{0} {1}".format "{0} {1}" format pos[-1] pos -1 ne pos[-1] -= ne pos[-1] pos -1 ne printAns(pos[-1], op) printAns pos[-1] pos -1 op def printAns(M, op):
    print(M)
    print(*op, sep='\n')
     printAns print(M) print M print(*op, sep='\n') print *op op sep='\n' sep '\n' M M op op if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    N = int(input())
    A = list(map(int,input().split()))
    neg = []
    pos = []
    for a in A:
        if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
    neg.sort()
    pos.sort()
    
    op = []
    if len(neg) == N:
        pos.append(neg[-1])
        neg.pop()
    
    if len(pos) == N:
        neg.append(pos[0])
        pos = pos[1:]
    
    for i in range(len(pos)-1):
        op.append("{0} {1}".format(neg[0], pos[i]))
        neg[0] -= pos[i]
    
    for ne in neg:
        op.append("{0} {1}".format(pos[-1], ne))
        pos[-1] -= ne
    
    printAns(pos[-1], op) def solve():
    N = int(input())
    A = list(map(int,input().split()))
    neg = []
    pos = []
    for a in A:
        if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
    neg.sort()
    pos.sort()
    
    op = []
    if len(neg) == N:
        pos.append(neg[-1])
        neg.pop()
    
    if len(pos) == N:
        neg.append(pos[0])
        pos = pos[1:]
    
    for i in range(len(pos)-1):
        op.append("{0} {1}".format(neg[0], pos[i]))
        neg[0] -= pos[i]
    
    for ne in neg:
        op.append("{0} {1}".format(pos[-1], ne))
        pos[-1] -= ne
    
    printAns(pos[-1], op) solve def printAns(M, op):
    print(M)
    print(*op, sep='\n')
     def printAns(M, op):
    print(M)
    print(*op, sep='\n')
     printAns
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    neg = []
    pos = []
    for a in A:
        if a < 0:
            neg.append(a)
        else:
            pos.append(a)
    
    neg.sort()
    pos.sort()
    
    op = []
    if len(neg) == N:
        pos.append(neg[-1])
        neg.pop()
    
    if len(pos) == N:
        neg.append(pos[0])
        pos = pos[1:]
    
    for i in range(len(pos)-1):
        op.append("{0} {1}".format(neg[0], pos[i]))
        neg[0] -= pos[i]
    
    for ne in neg:
        op.append("{0} {1}".format(pos[-1], ne))
        pos[-1] -= ne
    
    printAns(pos[-1], op)

def printAns(M, op):
    print(M)
    print(*op, sep='\n')
    
if __name__ == '__main__':
    solve()