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