import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b)

if __name__=='__main__':
    main() import sys sys def input(): return sys.stdin.readline().rstrip() input from collections import deque def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b) 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 A.sort(reverse=True) A.sort A sort reverse=True reverse True a for a in A if a>=0 for a in A if a>=0 a A a>=0 a 0 if a>=0 a Large=deque([a for a in A if a>=0]) Large deque([a for a in A if a>=0]) deque [a for a in A if a>=0] a for a in A if a<0 for a in A if a<0 a A a<0 a 0 if a<0 a Small=deque([a for a in A if a<0]) Small deque([a for a in A if a<0]) deque [a for a in A if a<0] if not Large:Large.append(Small.popleft())
     not Large Large if not Small:Small.append(Large.pop())
     not Small Small ans=[] ans [] while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
     len(Small)>=2 len(Small) len Small 2 a,b=Large.pop(),Small.pop() a Large.pop() Large.pop Large pop b Small.pop() Small.pop Small pop ans.append((a,b)) ans.append ans append (a,b) a b Large.append(a-b) Large.append Large append a-b a b small=Small.pop() small Small.pop() Small.pop Small pop while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
     len(Large)>=2 len(Large) len Large 2 a=Large.pop() a Large.pop() Large.pop Large pop ans.append((small,a)) ans.append ans append (small,a) small a small-=a small a large=Large.pop() large Large.pop() Large.pop Large pop ans.append((large,small)) ans.append ans append (large,small) large small print(large-small) print large-small large small for a,b in ans:
        print(a,b) a b ans print(a,b) print a b if __name__=='__main__':
    main() __name__=='__main__' __name__ '__main__' main() main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b) def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b) main
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b)

if __name__=='__main__':
    main()