# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[x for x in A if x>=0]
C=[x for x in A if x<0]
ans=[]
if B and C:
    P=B.pop()
    M=C.pop()
    for x in B:
        ans.append((M,x))
        M-=x
    for x in C:
        ans.append((P,x))
        P-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row)
elif B:
    M=B[0]
    P=B.pop()
    for x in B[1:]:
        ans.append((M,x))
        M-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row)
else:
    P=C.pop()
    for x in C:
        ans.append((P,x))
        P-=x
    print(P)
    for row in ans:
        print(*row) import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 INF=10**18 INF 10**18 10 18 MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 input=lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip YesNo=lambda b: bool([print('Yes')] if b else print('No')) YesNo lambda b: bool([print('Yes')] if b else print('No')) bool([print('Yes')] if b else print('No')) bool [print('Yes')] if b else print('No') b [print('Yes')] print('Yes') print 'Yes' print('No') print 'No' b YESNO=lambda b: bool([print('YES')] if b else print('NO')) YESNO lambda b: bool([print('YES')] if b else print('NO')) bool([print('YES')] if b else print('NO')) bool [print('YES')] if b else print('NO') b [print('YES')] print('YES') print 'YES' print('NO') print 'NO' b int1=lambda x:int(x)-1 int1 lambda x:int(x)-1 int(x)-1 int(x) int x 1 x 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() A.sort A sort x for x in A if x>=0 for x in A if x>=0 x A x>=0 x 0 if x>=0 x B=[x for x in A if x>=0] B [x for x in A if x>=0] x for x in A if x<0 for x in A if x<0 x A x<0 x 0 if x<0 x C=[x for x in A if x<0] C [x for x in A if x<0] ans=[] ans [] if B and C:
    P=B.pop()
    M=C.pop()
    for x in B:
        ans.append((M,x))
        M-=x
    for x in C:
        ans.append((P,x))
        P-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row)
elif B:
    M=B[0]
    P=B.pop()
    for x in B[1:]:
        ans.append((M,x))
        M-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row)
else:
    P=C.pop()
    for x in C:
        ans.append((P,x))
        P-=x
    print(P)
    for row in ans:
        print(*row) B and C B C P=B.pop() P B.pop() B.pop B pop M=C.pop() M C.pop() C.pop C pop for x in B:
        ans.append((M,x))
        M-=x
     x B ans.append((M,x)) ans.append ans append (M,x) M x M-=x M x for x in C:
        ans.append((P,x))
        P-=x
     x C ans.append((P,x)) ans.append ans append (P,x) P x P-=x P x ans.append((P,M)) ans.append ans append (P,M) P M P-=M P M print(P) print P for row in ans:
        print(*row) row ans print(*row) print *row row elif B:
    M=B[0]
    P=B.pop()
    for x in B[1:]:
        ans.append((M,x))
        M-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row) B M=B[0] M B[0] B 0 P=B.pop() P B.pop() B.pop B pop for x in B[1:]:
        ans.append((M,x))
        M-=x
     x B[1:] B 1: 1 ans.append((M,x)) ans.append ans append (M,x) M x M-=x M x ans.append((P,M)) ans.append ans append (P,M) P M P-=M P M print(P) print P for row in ans:
        print(*row) row ans print(*row) print *row row P=C.pop() P C.pop() C.pop C pop for x in C:
        ans.append((P,x))
        P-=x
     x C ans.append((P,x)) ans.append ans append (P,x) P x P-=x P x print(P) print P for row in ans:
        print(*row) row ans print(*row) print *row row P=C.pop() C.pop() P YesNo=lambda b: bool([print('Yes')] if b else print('No')) lambda b: bool([print('Yes')] if b else print('No')) YesNo M-=x x M M=C.pop() C.pop() M N=int(input()) int(input()) N P=B.pop() B.pop() P input=lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input B=[x for x in A if x>=0] [x for x in A if x>=0] B C=[x for x in A if x<0] [x for x in A if x<0] C P-=x x P MOD=10**9+7 10**9+7 MOD P=B.pop() B.pop() P INF=10**18 10**18 INF YESNO=lambda b: bool([print('YES')] if b else print('NO')) lambda b: bool([print('YES')] if b else print('NO')) YESNO M=B[0] B[0] M ans=[] [] ans P-=x x P int1=lambda x:int(x)-1 lambda x:int(x)-1 int1 P-=M M P M-=x x M A=list(map(int,input().split())) list(map(int,input().split())) A P-=M M P
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[x for x in A if x>=0]
C=[x for x in A if x<0]
ans=[]
if B and C:
    P=B.pop()
    M=C.pop()
    for x in B:
        ans.append((M,x))
        M-=x
    for x in C:
        ans.append((P,x))
        P-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row)
elif B:
    M=B[0]
    P=B.pop()
    for x in B[1:]:
        ans.append((M,x))
        M-=x
    ans.append((P,M))
    P-=M
    print(P)
    for row in ans:
        print(*row)
else:
    P=C.pop()
    for x in C:
        ans.append((P,x))
        P-=x
    print(P)
    for row in ans:
        print(*row)