from collections import deque
def solve1():
    print(sum(A)-min(A)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l)
def solve2():
    li=list(map(abs,A))
    print(sum(li)-min(li)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m)
def solve3():
    li=list(map(abs,A))
    print(sum(li))
    minus,plus=[],[]
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    mque,pque=deque(sorted(minus)),deque(sorted(plus))
    for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m)
N=int(input())
A=sorted(map(int,input().split()))

if min(A)>=0:
    solve1()
elif max(A)<=0:
    solve2()
else:
    solve3() from collections import deque def solve1():
    print(sum(A)-min(A)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l) solve1 print(sum(A)-min(A)*2) print sum(A)-min(A)*2 sum(A) sum A min(A)*2 min(A) min A 2 que=deque(A) que deque(A) deque A while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l) len(que)>1 len(que) len que 1 l,r=que.popleft(),que.pop() l que.popleft() que.popleft que popleft r que.pop() que.pop que pop if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l) que or (not que and l-r>=r-l) que not que and l-r>=r-l not que que l-r>=r-l l-r l r r-l r l print(l,r) print l r m=l-r m l-r l r que.appendleft(m) que.appendleft que appendleft m print(r,l) print r l def solve2():
    li=list(map(abs,A))
    print(sum(li)-min(li)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m) solve2 li=list(map(abs,A)) li list(map(abs,A)) list map(abs,A) map abs A print(sum(li)-min(li)*2) print sum(li)-min(li)*2 sum(li) sum li min(li)*2 min(li) min li 2 que=deque(A) que deque(A) deque A while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m) len(que)>1 len(que) len que 1 l,r=que.popleft(),que.pop() l que.popleft() que.popleft que popleft r que.pop() que.pop que pop if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
         que or (not que and r-l>=l-r) que not que and r-l>=l-r not que que r-l>=l-r r-l r l l-r l r print(r,l) print r l m=r-l m r-l r l print(l,r) print l r que.append(m) que.append que append m def solve3():
    li=list(map(abs,A))
    print(sum(li))
    minus,plus=[],[]
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    mque,pque=deque(sorted(minus)),deque(sorted(plus))
    for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m) solve3 li=list(map(abs,A)) li list(map(abs,A)) list map(abs,A) map abs A print(sum(li)) print sum(li) sum li minus,plus=[],[] minus [] plus [] for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
     i range(N) range N if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
     A[i]>=0 A[i] A i 0 plus.append(A[i]) plus.append plus append A[i] A i minus.append(A[i]) minus.append minus append A[i] A i mque,pque=deque(sorted(minus)),deque(sorted(plus)) mque deque(sorted(minus)) deque sorted(minus) sorted minus pque deque(sorted(plus)) deque sorted(plus) sorted plus for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m) i range(N-1) range N-1 N 1 m,p=mque.pop(),pque.pop() m mque.pop() mque.pop mque pop p pque.pop() pque.pop pque pop if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m) i==N-2 i N-2 N 2 print(p,m) print p m if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m) len(mque)==0 len(mque) len mque 0 print(m,p) print m p mque.append(m-p) mque.append mque append m-p m p print(p,m) print p m pque.append(p-m) pque.append pque append p-m p m N=int(input()) N int(input()) int input() input A=sorted(map(int,input().split())) A sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split if min(A)>=0:
    solve1()
elif max(A)<=0:
    solve2()
else:
    solve3() min(A)>=0 min(A) min A 0 solve1() solve1 elif max(A)<=0:
    solve2() max(A)<=0 max(A) max A 0 solve2() solve2 solve3() solve3 N=int(input()) int(input()) N def solve2():
    li=list(map(abs,A))
    print(sum(li)-min(li)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m) def solve2():
    li=list(map(abs,A))
    print(sum(li)-min(li)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m) solve2 A=sorted(map(int,input().split())) sorted(map(int,input().split())) A def solve1():
    print(sum(A)-min(A)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l) def solve1():
    print(sum(A)-min(A)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l) solve1 def solve3():
    li=list(map(abs,A))
    print(sum(li))
    minus,plus=[],[]
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    mque,pque=deque(sorted(minus)),deque(sorted(plus))
    for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m) def solve3():
    li=list(map(abs,A))
    print(sum(li))
    minus,plus=[],[]
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    mque,pque=deque(sorted(minus)),deque(sorted(plus))
    for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m) solve3
from collections import deque
def solve1():
    print(sum(A)-min(A)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and l-r>=r-l):
            print(l,r)
            m=l-r
            que.appendleft(m)
        else:
            print(r,l)
def solve2():
    li=list(map(abs,A))
    print(sum(li)-min(li)*2)
    que=deque(A)
    while(len(que)>1):
        l,r=que.popleft(),que.pop()
        if que or (not que and r-l>=l-r):
            print(r,l)
            m=r-l
        else:
            print(l,r)
        que.append(m)
def solve3():
    li=list(map(abs,A))
    print(sum(li))
    minus,plus=[],[]
    for i in range(N):
        if A[i]>=0:
            plus.append(A[i])
        else:
            minus.append(A[i])
    mque,pque=deque(sorted(minus)),deque(sorted(plus))
    for i in range(N-1):
        m,p=mque.pop(),pque.pop()
        if i==N-2:
            print(p,m)
        else:
            if len(mque)==0:
                print(m,p)
                mque.append(m-p)
            else:
                print(p,m)
                pque.append(p-m)
N=int(input())
A=sorted(map(int,input().split()))

if min(A)>=0:
    solve1()
elif max(A)<=0:
    solve2()
else:
    solve3()