n = int(input())
a = [int(i) for i in input().split()]
pos = [i for i in a if i >= 0]
neg = [i for i in a if i < 0]
cntp = len(pos)
cntn = len(neg)
lst = []

if pos and neg:
    for i in range(1,cntp):
        lst.append((neg[0],pos[i]))
        neg[0] -= pos[i]
    for i in range(1,cntn):
        lst.append((pos[0],neg[i]))
        pos[0] -= neg[i]
    lst.append((pos[0],neg[0]))
    maxv = pos[0]-neg[0]
elif pos:
    pos.sort()
    for i in range(1,cntp-1):
        lst.append((pos[0],pos[i]))
        pos[0] -= pos[i]
    lst.append((pos[cntp-1],pos[0]))
    maxv = pos[cntp-1]-pos[0]
else:
    neg.sort(reverse=True)
    for i in range(1,cntn):
        lst.append((neg[0],neg[i]))
        neg[0] -= neg[i]
    maxv = neg[0]
print(maxv)
for x,y in lst: print(x,y) n = int(input()) n int(input()) int input() input int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a = [int(i) for i in input().split()] a [int(i) for i in 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 pos = [i for i in a if i >= 0] pos [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 neg = [i for i in a if i < 0] neg [i for i in a if i < 0] cntp = len(pos) cntp len(pos) len pos cntn = len(neg) cntn len(neg) len neg lst = [] lst [] if pos and neg:
    for i in range(1,cntp):
        lst.append((neg[0],pos[i]))
        neg[0] -= pos[i]
    for i in range(1,cntn):
        lst.append((pos[0],neg[i]))
        pos[0] -= neg[i]
    lst.append((pos[0],neg[0]))
    maxv = pos[0]-neg[0]
elif pos:
    pos.sort()
    for i in range(1,cntp-1):
        lst.append((pos[0],pos[i]))
        pos[0] -= pos[i]
    lst.append((pos[cntp-1],pos[0]))
    maxv = pos[cntp-1]-pos[0]
else:
    neg.sort(reverse=True)
    for i in range(1,cntn):
        lst.append((neg[0],neg[i]))
        neg[0] -= neg[i]
    maxv = neg[0] pos and neg pos neg for i in range(1,cntp):
        lst.append((neg[0],pos[i]))
        neg[0] -= pos[i]
     i range(1,cntp) range 1 cntp lst.append((neg[0],pos[i])) lst.append lst append (neg[0],pos[i]) neg[0] neg 0 pos[i] pos i neg[0] -= pos[i] neg[0] neg 0 pos[i] pos i for i in range(1,cntn):
        lst.append((pos[0],neg[i]))
        pos[0] -= neg[i]
     i range(1,cntn) range 1 cntn lst.append((pos[0],neg[i])) lst.append lst append (pos[0],neg[i]) pos[0] pos 0 neg[i] neg i pos[0] -= neg[i] pos[0] pos 0 neg[i] neg i lst.append((pos[0],neg[0])) lst.append lst append (pos[0],neg[0]) pos[0] pos 0 neg[0] neg 0 maxv = pos[0]-neg[0] maxv pos[0]-neg[0] pos[0] pos 0 neg[0] neg 0 elif pos:
    pos.sort()
    for i in range(1,cntp-1):
        lst.append((pos[0],pos[i]))
        pos[0] -= pos[i]
    lst.append((pos[cntp-1],pos[0]))
    maxv = pos[cntp-1]-pos[0] pos pos.sort() pos.sort pos sort for i in range(1,cntp-1):
        lst.append((pos[0],pos[i]))
        pos[0] -= pos[i]
     i range(1,cntp-1) range 1 cntp-1 cntp 1 lst.append((pos[0],pos[i])) lst.append lst append (pos[0],pos[i]) pos[0] pos 0 pos[i] pos i pos[0] -= pos[i] pos[0] pos 0 pos[i] pos i lst.append((pos[cntp-1],pos[0])) lst.append lst append (pos[cntp-1],pos[0]) pos[cntp-1] pos cntp-1 cntp 1 pos[0] pos 0 maxv = pos[cntp-1]-pos[0] maxv pos[cntp-1]-pos[0] pos[cntp-1] pos cntp-1 cntp 1 pos[0] pos 0 neg.sort(reverse=True) neg.sort neg sort reverse=True reverse True for i in range(1,cntn):
        lst.append((neg[0],neg[i]))
        neg[0] -= neg[i]
     i range(1,cntn) range 1 cntn lst.append((neg[0],neg[i])) lst.append lst append (neg[0],neg[i]) neg[0] neg 0 neg[i] neg i neg[0] -= neg[i] neg[0] neg 0 neg[i] neg i maxv = neg[0] maxv neg[0] neg 0 print(maxv) print maxv for x,y in lst: print(x,y) x y lst n = int(input()) int(input()) n maxv = pos[0]-neg[0] pos[0]-neg[0] maxv maxv = neg[0] neg[0] maxv neg = [i for i in a if i < 0] [i for i in a if i < 0] neg pos = [i for i in a if i >= 0] [i for i in a if i >= 0] pos cntn = len(neg) len(neg) cntn cntp = len(pos) len(pos) cntp maxv = pos[cntp-1]-pos[0] pos[cntp-1]-pos[0] maxv lst = [] [] lst a = [int(i) for i in input().split()] [int(i) for i in input().split()] a
n = int(input())
a = [int(i) for i in input().split()]
pos = [i for i in a if i >= 0]
neg = [i for i in a if i < 0]
cntp = len(pos)
cntn = len(neg)
lst = []

if pos and neg:
    for i in range(1,cntp):
        lst.append((neg[0],pos[i]))
        neg[0] -= pos[i]
    for i in range(1,cntn):
        lst.append((pos[0],neg[i]))
        pos[0] -= neg[i]
    lst.append((pos[0],neg[0]))
    maxv = pos[0]-neg[0]
elif pos:
    pos.sort()
    for i in range(1,cntp-1):
        lst.append((pos[0],pos[i]))
        pos[0] -= pos[i]
    lst.append((pos[cntp-1],pos[0]))
    maxv = pos[cntp-1]-pos[0]
else:
    neg.sort(reverse=True)
    for i in range(1,cntn):
        lst.append((neg[0],neg[i]))
        neg[0] -= neg[i]
    maxv = neg[0]
print(maxv)
for x,y in lst: print(x,y)