N=int(input())
plus=[]
other=[]
d=list(map(int,input().split()))
for num in d:
    if num>0:
        plus.append(num)
    else:
        other.append(num)
if len(plus)>0:
    K=len(plus)
    if K==1:
        data=[]
        ans=plus[0]
        for q in other:
            data.append((ans,q))
            ans+=abs(q)
        print(ans)
        for some in data:
            x,y=some
            print(x,y)

    else:
        data=[]
        if len(other)>=1:
            ans=other[-1]
            for some in plus[1:]:
                data.append((ans,some))
                ans-=some
            other[-1]=ans
            ans=plus[0]
            for q in other:
                data.append((ans,q))
                ans+=abs(q)
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
        else:
            plus.sort()
            ans=plus[0]
            for some in plus[1:-1]:
                data.append((ans,some))
                ans-=some
            data.append((plus[-1],ans))
            ans=plus[-1]-ans
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
            
elif len(plus)==0:
    other.sort(reverse=True)
    data=[]
    ans=other[0]
    for q in other[1:]:
        data.append((ans,q))
        ans+=abs(q)
    print(ans)
    for some in data:
        x,y=some
        print(x,y) N=int(input()) N int(input()) int input() input plus=[] plus [] other=[] other [] d=list(map(int,input().split())) d list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for num in d:
    if num>0:
        plus.append(num)
    else:
        other.append(num) num d if num>0:
        plus.append(num)
    else:
        other.append(num) num>0 num 0 plus.append(num) plus.append plus append num other.append(num) other.append other append num if len(plus)>0:
    K=len(plus)
    if K==1:
        data=[]
        ans=plus[0]
        for q in other:
            data.append((ans,q))
            ans+=abs(q)
        print(ans)
        for some in data:
            x,y=some
            print(x,y)

    else:
        data=[]
        if len(other)>=1:
            ans=other[-1]
            for some in plus[1:]:
                data.append((ans,some))
                ans-=some
            other[-1]=ans
            ans=plus[0]
            for q in other:
                data.append((ans,q))
                ans+=abs(q)
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
        else:
            plus.sort()
            ans=plus[0]
            for some in plus[1:-1]:
                data.append((ans,some))
                ans-=some
            data.append((plus[-1],ans))
            ans=plus[-1]-ans
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
            
elif len(plus)==0:
    other.sort(reverse=True)
    data=[]
    ans=other[0]
    for q in other[1:]:
        data.append((ans,q))
        ans+=abs(q)
    print(ans)
    for some in data:
        x,y=some
        print(x,y) len(plus)>0 len(plus) len plus 0 K=len(plus) K len(plus) len plus if K==1:
        data=[]
        ans=plus[0]
        for q in other:
            data.append((ans,q))
            ans+=abs(q)
        print(ans)
        for some in data:
            x,y=some
            print(x,y)

    else:
        data=[]
        if len(other)>=1:
            ans=other[-1]
            for some in plus[1:]:
                data.append((ans,some))
                ans-=some
            other[-1]=ans
            ans=plus[0]
            for q in other:
                data.append((ans,q))
                ans+=abs(q)
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
        else:
            plus.sort()
            ans=plus[0]
            for some in plus[1:-1]:
                data.append((ans,some))
                ans-=some
            data.append((plus[-1],ans))
            ans=plus[-1]-ans
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
             K==1 K 1 data=[] data [] ans=plus[0] ans plus[0] plus 0 for q in other:
            data.append((ans,q))
            ans+=abs(q)
         q other data.append((ans,q)) data.append data append (ans,q) ans q ans+=abs(q) ans abs(q) abs q print(ans) print ans for some in data:
            x,y=some
            print(x,y)

     some data x,y=some x some y print(x,y) print x y data=[] data [] if len(other)>=1:
            ans=other[-1]
            for some in plus[1:]:
                data.append((ans,some))
                ans-=some
            other[-1]=ans
            ans=plus[0]
            for q in other:
                data.append((ans,q))
                ans+=abs(q)
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
        else:
            plus.sort()
            ans=plus[0]
            for some in plus[1:-1]:
                data.append((ans,some))
                ans-=some
            data.append((plus[-1],ans))
            ans=plus[-1]-ans
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
             len(other)>=1 len(other) len other 1 ans=other[-1] ans other[-1] other -1 for some in plus[1:]:
                data.append((ans,some))
                ans-=some
             some plus[1:] plus 1: 1 data.append((ans,some)) data.append data append (ans,some) ans some ans-=some ans some other[-1]=ans other[-1] other -1 ans ans=plus[0] ans plus[0] plus 0 for q in other:
                data.append((ans,q))
                ans+=abs(q)
             q other data.append((ans,q)) data.append data append (ans,q) ans q ans+=abs(q) ans abs(q) abs q print(ans) print ans for some in data:
                x,y=some
                print(x,y)
         some data x,y=some x some y print(x,y) print x y plus.sort() plus.sort plus sort ans=plus[0] ans plus[0] plus 0 for some in plus[1:-1]:
                data.append((ans,some))
                ans-=some
             some plus[1:-1] plus 1:-1 1 -1 data.append((ans,some)) data.append data append (ans,some) ans some ans-=some ans some data.append((plus[-1],ans)) data.append data append (plus[-1],ans) plus[-1] plus -1 ans ans=plus[-1]-ans ans plus[-1]-ans plus[-1] plus -1 ans print(ans) print ans for some in data:
                x,y=some
                print(x,y)
             some data x,y=some x some y print(x,y) print x y elif len(plus)==0:
    other.sort(reverse=True)
    data=[]
    ans=other[0]
    for q in other[1:]:
        data.append((ans,q))
        ans+=abs(q)
    print(ans)
    for some in data:
        x,y=some
        print(x,y) len(plus)==0 len(plus) len plus 0 other.sort(reverse=True) other.sort other sort reverse=True reverse True data=[] data [] ans=other[0] ans other[0] other 0 for q in other[1:]:
        data.append((ans,q))
        ans+=abs(q)
     q other[1:] other 1: 1 data.append((ans,q)) data.append data append (ans,q) ans q ans+=abs(q) ans abs(q) abs q print(ans) print ans for some in data:
        x,y=some
        print(x,y) some data x,y=some x some y print(x,y) print x y plus=[] [] plus ans-=some some ans y=some some y data=[] [] data d=list(map(int,input().split())) list(map(int,input().split())) d data=[] [] data x,y=some some x N=int(input()) int(input()) N x,y=some some x K=len(plus) len(plus) K ans=plus[0] plus[0] ans ans+=abs(q) abs(q) ans ans=other[0] other[0] ans ans=other[-1] other[-1] ans y=some some y x,y=some some x x,y=some some x other=[] [] other y=some some y ans+=abs(q) abs(q) ans ans=plus[0] plus[0] ans data=[] [] data ans=plus[-1]-ans plus[-1]-ans ans ans=plus[0] plus[0] ans ans-=some some ans ans+=abs(q) abs(q) ans y=some some y
N=int(input())
plus=[]
other=[]
d=list(map(int,input().split()))
for num in d:
    if num>0:
        plus.append(num)
    else:
        other.append(num)
if len(plus)>0:
    K=len(plus)
    if K==1:
        data=[]
        ans=plus[0]
        for q in other:
            data.append((ans,q))
            ans+=abs(q)
        print(ans)
        for some in data:
            x,y=some
            print(x,y)

    else:
        data=[]
        if len(other)>=1:
            ans=other[-1]
            for some in plus[1:]:
                data.append((ans,some))
                ans-=some
            other[-1]=ans
            ans=plus[0]
            for q in other:
                data.append((ans,q))
                ans+=abs(q)
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
        else:
            plus.sort()
            ans=plus[0]
            for some in plus[1:-1]:
                data.append((ans,some))
                ans-=some
            data.append((plus[-1],ans))
            ans=plus[-1]-ans
            print(ans)
            for some in data:
                x,y=some
                print(x,y)
            
elif len(plus)==0:
    other.sort(reverse=True)
    data=[]
    ans=other[0]
    for q in other[1:]:
        data.append((ans,q))
        ans+=abs(q)
    print(ans)
    for some in data:
        x,y=some
        print(x,y)
