n=int(input())
a=list(map(int,input().split()))
a.sort()
minus=[i for i in a if i<0]
plus=[i for i in a if i>=0]
if len(minus)==0:
    print(a[-1]-a[0]+sum(a[1:n-1]))
    for i in range(n-1):
        if i==n-2:
            print(a[-1],a[n-2])
        else:
            print(a[i],a[i+1])
            a[i+1]=a[i]-a[i+1]
elif len(plus)==0:
    print(a[-1]-a[0]-sum(a[1:n-1]))
    print(a[-1],a[0])
    a[-1]=a[-1]-a[0]
    for i in range(1,n-1):
        print(a[-1],a[i])
        a[-1]-=a[i]
else:
    print(a[-1]-a[0]-sum(minus[1:])+sum(plus[0:-1]))
    for i in range(len(plus)-1):
        print(minus[0],plus[i])
        minus[0]-=plus[i]
    for i in range(len(minus)):
        print(a[-1],minus[i])
        a[-1]-=minus[i] 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 i for i in a if i<0 for i in a if i<0 i a i<0 i 0 if i<0 i minus=[i for i in a if i<0] minus [i for i in a if i<0] i for i in a if i>=0 for i in a if i>=0 i a i>=0 i 0 if i>=0 i plus=[i for i in a if i>=0] plus [i for i in a if i>=0] if len(minus)==0:
    print(a[-1]-a[0]+sum(a[1:n-1]))
    for i in range(n-1):
        if i==n-2:
            print(a[-1],a[n-2])
        else:
            print(a[i],a[i+1])
            a[i+1]=a[i]-a[i+1]
elif len(plus)==0:
    print(a[-1]-a[0]-sum(a[1:n-1]))
    print(a[-1],a[0])
    a[-1]=a[-1]-a[0]
    for i in range(1,n-1):
        print(a[-1],a[i])
        a[-1]-=a[i]
else:
    print(a[-1]-a[0]-sum(minus[1:])+sum(plus[0:-1]))
    for i in range(len(plus)-1):
        print(minus[0],plus[i])
        minus[0]-=plus[i]
    for i in range(len(minus)):
        print(a[-1],minus[i])
        a[-1]-=minus[i] len(minus)==0 len(minus) len minus 0 print(a[-1]-a[0]+sum(a[1:n-1])) print a[-1]-a[0]+sum(a[1:n-1]) a[-1]-a[0] a[-1] a -1 a[0] a 0 sum(a[1:n-1]) sum a[1:n-1] a 1:n-1 1 n-1 n 1 for i in range(n-1):
        if i==n-2:
            print(a[-1],a[n-2])
        else:
            print(a[i],a[i+1])
            a[i+1]=a[i]-a[i+1] i range(n-1) range n-1 n 1 if i==n-2:
            print(a[-1],a[n-2])
        else:
            print(a[i],a[i+1])
            a[i+1]=a[i]-a[i+1] i==n-2 i n-2 n 2 print(a[-1],a[n-2]) print a[-1] a -1 a[n-2] a n-2 n 2 print(a[i],a[i+1]) print a[i] a i a[i+1] a i+1 i 1 a[i+1]=a[i]-a[i+1] a[i+1] a i+1 i 1 a[i]-a[i+1] a[i] a i a[i+1] a i+1 i 1 elif len(plus)==0:
    print(a[-1]-a[0]-sum(a[1:n-1]))
    print(a[-1],a[0])
    a[-1]=a[-1]-a[0]
    for i in range(1,n-1):
        print(a[-1],a[i])
        a[-1]-=a[i] len(plus)==0 len(plus) len plus 0 print(a[-1]-a[0]-sum(a[1:n-1])) print a[-1]-a[0]-sum(a[1:n-1]) a[-1]-a[0] a[-1] a -1 a[0] a 0 sum(a[1:n-1]) sum a[1:n-1] a 1:n-1 1 n-1 n 1 print(a[-1],a[0]) print a[-1] a -1 a[0] a 0 a[-1]=a[-1]-a[0] a[-1] a -1 a[-1]-a[0] a[-1] a -1 a[0] a 0 for i in range(1,n-1):
        print(a[-1],a[i])
        a[-1]-=a[i] i range(1,n-1) range 1 n-1 n 1 print(a[-1],a[i]) print a[-1] a -1 a[i] a i a[-1]-=a[i] a[-1] a -1 a[i] a i print(a[-1]-a[0]-sum(minus[1:])+sum(plus[0:-1])) print a[-1]-a[0]-sum(minus[1:])+sum(plus[0:-1]) a[-1]-a[0]-sum(minus[1:]) a[-1]-a[0] a[-1] a -1 a[0] a 0 sum(minus[1:]) sum minus[1:] minus 1: 1 sum(plus[0:-1]) sum plus[0:-1] plus 0:-1 0 -1 for i in range(len(plus)-1):
        print(minus[0],plus[i])
        minus[0]-=plus[i]
     i range(len(plus)-1) range len(plus)-1 len(plus) len plus 1 print(minus[0],plus[i]) print minus[0] minus 0 plus[i] plus i minus[0]-=plus[i] minus[0] minus 0 plus[i] plus i for i in range(len(minus)):
        print(a[-1],minus[i])
        a[-1]-=minus[i] i range(len(minus)) range len(minus) len minus print(a[-1],minus[i]) print a[-1] a -1 minus[i] minus i a[-1]-=minus[i] a[-1] a -1 minus[i] minus i plus=[i for i in a if i>=0] [i for i in a if i>=0] plus n=int(input()) int(input()) n minus=[i for i in a if i<0] [i for i in a if i<0] minus a=list(map(int,input().split())) list(map(int,input().split())) a
n=int(input())
a=list(map(int,input().split()))
a.sort()
minus=[i for i in a if i<0]
plus=[i for i in a if i>=0]
if len(minus)==0:
    print(a[-1]-a[0]+sum(a[1:n-1]))
    for i in range(n-1):
        if i==n-2:
            print(a[-1],a[n-2])
        else:
            print(a[i],a[i+1])
            a[i+1]=a[i]-a[i+1]
elif len(plus)==0:
    print(a[-1]-a[0]-sum(a[1:n-1]))
    print(a[-1],a[0])
    a[-1]=a[-1]-a[0]
    for i in range(1,n-1):
        print(a[-1],a[i])
        a[-1]-=a[i]
else:
    print(a[-1]-a[0]-sum(minus[1:])+sum(plus[0:-1]))
    for i in range(len(plus)-1):
        print(minus[0],plus[i])
        minus[0]-=plus[i]
    for i in range(len(minus)):
        print(a[-1],minus[i])
        a[-1]-=minus[i]