N = int(input())
A = [int(x) for x in input().split()]
plus = [x for x in A if x > 0]
minus = [x for x in A if x <= 0]
plus.sort()
minus.sort()
minA = minus.pop() if minus else plus.pop(0)
M = sum(plus) - sum(minus)
M += -minA if plus else minA
print(M)
xy = minA
for i in range(N - 1):
  if len(plus) > 1:
    y = plus.pop()
    print('{} {}'.format(xy, y))
    xy -= y
  elif len(plus) == 1:
    x = plus.pop()
    print('{} {}'.format(x, xy))
    xy = x - xy
  else:
    y = minus.pop()
    print('{} {}'.format(xy, y))
    xy -= y N = int(input()) N int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x A = [int(x) for x in input().split()] A [int(x) for x in input().split()] x for x in A if x > 0 for x in A if x > 0 x A x > 0 x 0 if x > 0 x plus = [x for x in A if x > 0] plus [x for x in A if x > 0] x for x in A if x <= 0 for x in A if x <= 0 x A x <= 0 x 0 if x <= 0 x minus = [x for x in A if x <= 0] minus [x for x in A if x <= 0] plus.sort() plus.sort plus sort minus.sort() minus.sort minus sort minA = minus.pop() if minus else plus.pop(0) minA minus.pop() if minus else plus.pop(0) minus minus.pop() minus.pop minus pop plus.pop(0) plus.pop plus pop 0 M = sum(plus) - sum(minus) M sum(plus) - sum(minus) sum(plus) sum plus sum(minus) sum minus M += -minA if plus else minA M -minA if plus else minA plus -minA minA minA print(M) print M xy = minA xy minA for i in range(N - 1):
  if len(plus) > 1:
    y = plus.pop()
    print('{} {}'.format(xy, y))
    xy -= y
  elif len(plus) == 1:
    x = plus.pop()
    print('{} {}'.format(x, xy))
    xy = x - xy
  else:
    y = minus.pop()
    print('{} {}'.format(xy, y))
    xy -= y i range(N - 1) range N - 1 N 1 if len(plus) > 1:
    y = plus.pop()
    print('{} {}'.format(xy, y))
    xy -= y
  elif len(plus) == 1:
    x = plus.pop()
    print('{} {}'.format(x, xy))
    xy = x - xy
  else:
    y = minus.pop()
    print('{} {}'.format(xy, y))
    xy -= y len(plus) > 1 len(plus) len plus 1 y = plus.pop() y plus.pop() plus.pop plus pop print('{} {}'.format(xy, y)) print '{} {}'.format(xy, y) '{} {}'.format '{} {}' format xy y xy -= y xy y elif len(plus) == 1:
    x = plus.pop()
    print('{} {}'.format(x, xy))
    xy = x - xy
   len(plus) == 1 len(plus) len plus 1 x = plus.pop() x plus.pop() plus.pop plus pop print('{} {}'.format(x, xy)) print '{} {}'.format(x, xy) '{} {}'.format '{} {}' format x xy xy = x - xy xy x - xy x xy y = minus.pop() y minus.pop() minus.pop minus pop print('{} {}'.format(xy, y)) print '{} {}'.format(xy, y) '{} {}'.format '{} {}' format xy y xy -= y xy y plus = [x for x in A if x > 0] [x for x in A if x > 0] plus M = sum(plus) - sum(minus) sum(plus) - sum(minus) M xy -= y y xy minus = [x for x in A if x <= 0] [x for x in A if x <= 0] minus y = plus.pop() plus.pop() y minA = minus.pop() if minus else plus.pop(0) minus.pop() if minus else plus.pop(0) minA xy = minA minA xy N = int(input()) int(input()) N M += -minA if plus else minA -minA if plus else minA M A = [int(x) for x in input().split()] [int(x) for x in input().split()] A y = minus.pop() minus.pop() y xy = x - xy x - xy xy x = plus.pop() plus.pop() x xy -= y y xy
N = int(input())
A = [int(x) for x in input().split()]
plus = [x for x in A if x > 0]
minus = [x for x in A if x <= 0]
plus.sort()
minus.sort()
minA = minus.pop() if minus else plus.pop(0)
M = sum(plus) - sum(minus)
M += -minA if plus else minA
print(M)
xy = minA
for i in range(N - 1):
  if len(plus) > 1:
    y = plus.pop()
    print('{} {}'.format(xy, y))
    xy -= y
  elif len(plus) == 1:
    x = plus.pop()
    print('{} {}'.format(x, xy))
    xy = x - xy
  else:
    y = minus.pop()
    print('{} {}'.format(xy, y))
    xy -= y