
from collections import deque
N=int(input())
A=list(map(int, input().split()))

# プラス　マイナス引いていく
plus=[]
minus=[]
zeros=[]
for a in A:
    if a==0:
        zeros.append(a)
    elif a>=1:
        plus.append(a)
    else:
        minus.append(a)
plus=sorted(plus)
minus=sorted(minus)
zeros=sorted(zeros)
ans=[]
if plus and minus:
    while len(plus)>1:
        now=plus.pop()
        ans.append((minus[0],now))
        minus[0]-=now
    while len(zeros)>0:
        now=zeros.pop()
        ans.append((plus[0],now))
    while len(minus)>1:
        now=minus.pop()
        ans.append((plus[0],now))
        plus[0]-=now
    ans.append((plus[0],minus[0]))
    ansnum=plus[0]-minus[0]
else:
    ansnum=0
    if len(plus)==0:
        if zeros:
            core=zeros.pop()
        else:
            core=minus.pop()
        while len(minus)>0:
            now=minus.pop()
            ans.append((core,now))
            core-=now
        ansnum=core
    else:
        if zeros:
            core=zeros.pop()
        else:
            plus=deque(plus)
            core=plus.popleft()
        while len(plus)>1:
            now=plus.pop()
            ans.append((core,now))
            core-=now
        ans.append((plus[0],core))
        ansnum=plus[0]-core
        core=ansnum
    while len(zeros)>0:
        now=zeros.pop()
        ans.append((core,now))
    
    

print(ansnum)
for t in ans:
    x,y=t
    print(x,y) from collections import deque 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 plus=[] plus [] minus=[] minus [] zeros=[] zeros [] for a in A:
    if a==0:
        zeros.append(a)
    elif a>=1:
        plus.append(a)
    else:
        minus.append(a) a A if a==0:
        zeros.append(a)
    elif a>=1:
        plus.append(a)
    else:
        minus.append(a) a==0 a 0 zeros.append(a) zeros.append zeros append a elif a>=1:
        plus.append(a)
     a>=1 a 1 plus.append(a) plus.append plus append a minus.append(a) minus.append minus append a plus=sorted(plus) plus sorted(plus) sorted plus minus=sorted(minus) minus sorted(minus) sorted minus zeros=sorted(zeros) zeros sorted(zeros) sorted zeros ans=[] ans [] if plus and minus:
    while len(plus)>1:
        now=plus.pop()
        ans.append((minus[0],now))
        minus[0]-=now
    while len(zeros)>0:
        now=zeros.pop()
        ans.append((plus[0],now))
    while len(minus)>1:
        now=minus.pop()
        ans.append((plus[0],now))
        plus[0]-=now
    ans.append((plus[0],minus[0]))
    ansnum=plus[0]-minus[0]
else:
    ansnum=0
    if len(plus)==0:
        if zeros:
            core=zeros.pop()
        else:
            core=minus.pop()
        while len(minus)>0:
            now=minus.pop()
            ans.append((core,now))
            core-=now
        ansnum=core
    else:
        if zeros:
            core=zeros.pop()
        else:
            plus=deque(plus)
            core=plus.popleft()
        while len(plus)>1:
            now=plus.pop()
            ans.append((core,now))
            core-=now
        ans.append((plus[0],core))
        ansnum=plus[0]-core
        core=ansnum
    while len(zeros)>0:
        now=zeros.pop()
        ans.append((core,now))
    
     plus and minus plus minus while len(plus)>1:
        now=plus.pop()
        ans.append((minus[0],now))
        minus[0]-=now
     len(plus)>1 len(plus) len plus 1 now=plus.pop() now plus.pop() plus.pop plus pop ans.append((minus[0],now)) ans.append ans append (minus[0],now) minus[0] minus 0 now minus[0]-=now minus[0] minus 0 now while len(zeros)>0:
        now=zeros.pop()
        ans.append((plus[0],now))
     len(zeros)>0 len(zeros) len zeros 0 now=zeros.pop() now zeros.pop() zeros.pop zeros pop ans.append((plus[0],now)) ans.append ans append (plus[0],now) plus[0] plus 0 now while len(minus)>1:
        now=minus.pop()
        ans.append((plus[0],now))
        plus[0]-=now
     len(minus)>1 len(minus) len minus 1 now=minus.pop() now minus.pop() minus.pop minus pop ans.append((plus[0],now)) ans.append ans append (plus[0],now) plus[0] plus 0 now plus[0]-=now plus[0] plus 0 now ans.append((plus[0],minus[0])) ans.append ans append (plus[0],minus[0]) plus[0] plus 0 minus[0] minus 0 ansnum=plus[0]-minus[0] ansnum plus[0]-minus[0] plus[0] plus 0 minus[0] minus 0 ansnum=0 ansnum 0 if len(plus)==0:
        if zeros:
            core=zeros.pop()
        else:
            core=minus.pop()
        while len(minus)>0:
            now=minus.pop()
            ans.append((core,now))
            core-=now
        ansnum=core
    else:
        if zeros:
            core=zeros.pop()
        else:
            plus=deque(plus)
            core=plus.popleft()
        while len(plus)>1:
            now=plus.pop()
            ans.append((core,now))
            core-=now
        ans.append((plus[0],core))
        ansnum=plus[0]-core
        core=ansnum
     len(plus)==0 len(plus) len plus 0 if zeros:
            core=zeros.pop()
        else:
            core=minus.pop()
         zeros core=zeros.pop() core zeros.pop() zeros.pop zeros pop core=minus.pop() core minus.pop() minus.pop minus pop while len(minus)>0:
            now=minus.pop()
            ans.append((core,now))
            core-=now
         len(minus)>0 len(minus) len minus 0 now=minus.pop() now minus.pop() minus.pop minus pop ans.append((core,now)) ans.append ans append (core,now) core now core-=now core now ansnum=core ansnum core if zeros:
            core=zeros.pop()
        else:
            plus=deque(plus)
            core=plus.popleft()
         zeros core=zeros.pop() core zeros.pop() zeros.pop zeros pop plus=deque(plus) plus deque(plus) deque plus core=plus.popleft() core plus.popleft() plus.popleft plus popleft while len(plus)>1:
            now=plus.pop()
            ans.append((core,now))
            core-=now
         len(plus)>1 len(plus) len plus 1 now=plus.pop() now plus.pop() plus.pop plus pop ans.append((core,now)) ans.append ans append (core,now) core now core-=now core now ans.append((plus[0],core)) ans.append ans append (plus[0],core) plus[0] plus 0 core ansnum=plus[0]-core ansnum plus[0]-core plus[0] plus 0 core core=ansnum core ansnum while len(zeros)>0:
        now=zeros.pop()
        ans.append((core,now))
    
     len(zeros)>0 len(zeros) len zeros 0 now=zeros.pop() now zeros.pop() zeros.pop zeros pop ans.append((core,now)) ans.append ans append (core,now) core now print(ansnum) print ansnum for t in ans:
    x,y=t
    print(x,y) t ans x,y=t x t y print(x,y) print x y zeros=[] [] zeros core=minus.pop() minus.pop() core plus=[] [] plus core-=now now core A=list(map(int, input().split())) list(map(int, input().split())) A ansnum=plus[0]-core plus[0]-core ansnum core-=now now core now=plus.pop() plus.pop() now now=minus.pop() minus.pop() now core=ansnum ansnum core minus=[] [] minus now=plus.pop() plus.pop() now now=minus.pop() minus.pop() now ansnum=0 0 ansnum now=zeros.pop() zeros.pop() now core=zeros.pop() zeros.pop() core core=plus.popleft() plus.popleft() core ansnum=core core ansnum x,y=t t x ans=[] [] ans plus=sorted(plus) sorted(plus) plus y=t t y now=zeros.pop() zeros.pop() now N=int(input()) int(input()) N core=zeros.pop() zeros.pop() core zeros=sorted(zeros) sorted(zeros) zeros ansnum=plus[0]-minus[0] plus[0]-minus[0] ansnum plus=deque(plus) deque(plus) plus minus=sorted(minus) sorted(minus) minus

from collections import deque
N=int(input())
A=list(map(int, input().split()))

# プラス　マイナス引いていく
plus=[]
minus=[]
zeros=[]
for a in A:
    if a==0:
        zeros.append(a)
    elif a>=1:
        plus.append(a)
    else:
        minus.append(a)
plus=sorted(plus)
minus=sorted(minus)
zeros=sorted(zeros)
ans=[]
if plus and minus:
    while len(plus)>1:
        now=plus.pop()
        ans.append((minus[0],now))
        minus[0]-=now
    while len(zeros)>0:
        now=zeros.pop()
        ans.append((plus[0],now))
    while len(minus)>1:
        now=minus.pop()
        ans.append((plus[0],now))
        plus[0]-=now
    ans.append((plus[0],minus[0]))
    ansnum=plus[0]-minus[0]
else:
    ansnum=0
    if len(plus)==0:
        if zeros:
            core=zeros.pop()
        else:
            core=minus.pop()
        while len(minus)>0:
            now=minus.pop()
            ans.append((core,now))
            core-=now
        ansnum=core
    else:
        if zeros:
            core=zeros.pop()
        else:
            plus=deque(plus)
            core=plus.popleft()
        while len(plus)>1:
            now=plus.pop()
            ans.append((core,now))
            core-=now
        ans.append((plus[0],core))
        ansnum=plus[0]-core
        core=ansnum
    while len(zeros)>0:
        now=zeros.pop()
        ans.append((core,now))
    
    

print(ansnum)
for t in ans:
    x,y=t
    print(x,y)