n=int(input())
a=list(map(int,input().split()))
plus=[a[i] for i in range(n) if a[i]>=0]
l_plus=len(plus)
minus=[a[i] for i in range(n) if a[i]<0]
l_minus=len(minus)
x_cal=[]
y_cal=[]
if n==2:
  a.sort()
  print(a[1]-a[0])
  print(a[0],a[1])
else:
  if plus!=[] and minus!=[]:
    if l_plus>1:
      x_cal.append(minus[0])
    for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
    for k in range(1,l_plus):
      y_cal.append(plus[k])
    if l_plus>1:
      y_last=x_cal[-1]-y_cal[-1]
    else:
      y_last=minus[0]
    x_cal.append(plus[0])
    for j in range(1,l_minus):
      x_cal.append(x_cal[-1]-minus[j])
    for k in range(1,l_minus):
      y_cal.append(minus[k])
    y_cal.append(y_last)
    print(x_cal[-1]-y_cal[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  else:
    a.sort()
    print(a[-1]*2-sum(a))
    x_cal.append(a[-1])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    x_cal.append(x_cal[-1]-y_cal[-1])
    y_cal.append(a[0])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii]) 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[i] for i in range(n) if a[i]>=0 for i in range(n) if a[i]>=0 i range(n) range n a[i]>=0 a[i] a i 0 if a[i]>=0 a[i] a i plus=[a[i] for i in range(n) if a[i]>=0] plus [a[i] for i in range(n) if a[i]>=0] l_plus=len(plus) l_plus len(plus) len plus a[i] for i in range(n) if a[i]<0 for i in range(n) if a[i]<0 i range(n) range n a[i]<0 a[i] a i 0 if a[i]<0 a[i] a i minus=[a[i] for i in range(n) if a[i]<0] minus [a[i] for i in range(n) if a[i]<0] l_minus=len(minus) l_minus len(minus) len minus x_cal=[] x_cal [] y_cal=[] y_cal [] if n==2:
  a.sort()
  print(a[1]-a[0])
  print(a[0],a[1])
else:
  if plus!=[] and minus!=[]:
    if l_plus>1:
      x_cal.append(minus[0])
    for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
    for k in range(1,l_plus):
      y_cal.append(plus[k])
    if l_plus>1:
      y_last=x_cal[-1]-y_cal[-1]
    else:
      y_last=minus[0]
    x_cal.append(plus[0])
    for j in range(1,l_minus):
      x_cal.append(x_cal[-1]-minus[j])
    for k in range(1,l_minus):
      y_cal.append(minus[k])
    y_cal.append(y_last)
    print(x_cal[-1]-y_cal[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  else:
    a.sort()
    print(a[-1]*2-sum(a))
    x_cal.append(a[-1])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    x_cal.append(x_cal[-1]-y_cal[-1])
    y_cal.append(a[0])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii]) n==2 n 2 a.sort() a.sort a sort print(a[1]-a[0]) print a[1]-a[0] a[1] a 1 a[0] a 0 print(a[0],a[1]) print a[0] a 0 a[1] a 1 if plus!=[] and minus!=[]:
    if l_plus>1:
      x_cal.append(minus[0])
    for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
    for k in range(1,l_plus):
      y_cal.append(plus[k])
    if l_plus>1:
      y_last=x_cal[-1]-y_cal[-1]
    else:
      y_last=minus[0]
    x_cal.append(plus[0])
    for j in range(1,l_minus):
      x_cal.append(x_cal[-1]-minus[j])
    for k in range(1,l_minus):
      y_cal.append(minus[k])
    y_cal.append(y_last)
    print(x_cal[-1]-y_cal[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  else:
    a.sort()
    print(a[-1]*2-sum(a))
    x_cal.append(a[-1])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    x_cal.append(x_cal[-1]-y_cal[-1])
    y_cal.append(a[0])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii]) plus!=[] and minus!=[] plus!=[] plus [] minus!=[] minus [] if l_plus>1:
      x_cal.append(minus[0])
     l_plus>1 l_plus 1 x_cal.append(minus[0]) x_cal.append x_cal append minus[0] minus 0 for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
     j range(1,l_plus-1) range 1 l_plus-1 l_plus 1 x_cal.append(x_cal[-1]-plus[j]) x_cal.append x_cal append x_cal[-1]-plus[j] x_cal[-1] x_cal -1 plus[j] plus j for k in range(1,l_plus):
      y_cal.append(plus[k])
     k range(1,l_plus) range 1 l_plus y_cal.append(plus[k]) y_cal.append y_cal append plus[k] plus k if l_plus>1:
      y_last=x_cal[-1]-y_cal[-1]
    else:
      y_last=minus[0]
     l_plus>1 l_plus 1 y_last=x_cal[-1]-y_cal[-1] y_last x_cal[-1]-y_cal[-1] x_cal[-1] x_cal -1 y_cal[-1] y_cal -1 y_last=minus[0] y_last minus[0] minus 0 x_cal.append(plus[0]) x_cal.append x_cal append plus[0] plus 0 for j in range(1,l_minus):
      x_cal.append(x_cal[-1]-minus[j])
     j range(1,l_minus) range 1 l_minus x_cal.append(x_cal[-1]-minus[j]) x_cal.append x_cal append x_cal[-1]-minus[j] x_cal[-1] x_cal -1 minus[j] minus j for k in range(1,l_minus):
      y_cal.append(minus[k])
     k range(1,l_minus) range 1 l_minus y_cal.append(minus[k]) y_cal.append y_cal append minus[k] minus k y_cal.append(y_last) y_cal.append y_cal append y_last print(x_cal[-1]-y_cal[-1]) print x_cal[-1]-y_cal[-1] x_cal[-1] x_cal -1 y_cal[-1] y_cal -1 for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
   ii range(n-1) range n-1 n 1 print(x_cal[ii],y_cal[ii]) print x_cal[ii] x_cal ii y_cal[ii] y_cal ii elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
   minus==[] minus [] a.sort() a.sort a sort print(sum(a)-2*a[0]) print sum(a)-2*a[0] sum(a) sum a 2*a[0] 2 a[0] a 0 x_cal.append(a[0]) x_cal.append x_cal append a[0] a 0 for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
     ij range(1,n-2) range 1 n-2 n 2 x_cal.append(x_cal[-1]-a[ij]) x_cal.append x_cal append x_cal[-1]-a[ij] x_cal[-1] x_cal -1 a[ij] a ij for jj in range(0,n-2):
      y_cal.append(a[jj+1])
     jj range(0,n-2) range 0 n-2 n 2 y_cal.append(a[jj+1]) y_cal.append y_cal append a[jj+1] a jj+1 jj 1 y_cal.append(x_cal[-1]-y_cal[-1]) y_cal.append y_cal append x_cal[-1]-y_cal[-1] x_cal[-1] x_cal -1 y_cal[-1] y_cal -1 x_cal.append(a[-1]) x_cal.append x_cal append a[-1] a -1 for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
   ii range(n-1) range n-1 n 1 print(x_cal[ii],y_cal[ii]) print x_cal[ii] x_cal ii y_cal[ii] y_cal ii a.sort() a.sort a sort print(a[-1]*2-sum(a)) print a[-1]*2-sum(a) a[-1]*2 a[-1] a -1 2 sum(a) sum a x_cal.append(a[-1]) x_cal.append x_cal append a[-1] a -1 for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
     ij range(1,n-2) range 1 n-2 n 2 x_cal.append(x_cal[-1]-a[ij]) x_cal.append x_cal append x_cal[-1]-a[ij] x_cal[-1] x_cal -1 a[ij] a ij for jj in range(0,n-2):
      y_cal.append(a[jj+1])
     jj range(0,n-2) range 0 n-2 n 2 y_cal.append(a[jj+1]) y_cal.append y_cal append a[jj+1] a jj+1 jj 1 x_cal.append(x_cal[-1]-y_cal[-1]) x_cal.append x_cal append x_cal[-1]-y_cal[-1] x_cal[-1] x_cal -1 y_cal[-1] y_cal -1 y_cal.append(a[0]) y_cal.append y_cal append a[0] a 0 for ii in range(n-1):
      print(x_cal[ii],y_cal[ii]) ii range(n-1) range n-1 n 1 print(x_cal[ii],y_cal[ii]) print x_cal[ii] x_cal ii y_cal[ii] y_cal ii n=int(input()) int(input()) n plus=[a[i] for i in range(n) if a[i]>=0] [a[i] for i in range(n) if a[i]>=0] plus l_plus=len(plus) len(plus) l_plus l_minus=len(minus) len(minus) l_minus minus=[a[i] for i in range(n) if a[i]<0] [a[i] for i in range(n) if a[i]<0] minus a=list(map(int,input().split())) list(map(int,input().split())) a x_cal=[] [] x_cal y_cal=[] [] y_cal y_last=x_cal[-1]-y_cal[-1] x_cal[-1]-y_cal[-1] y_last y_last=minus[0] minus[0] y_last
n=int(input())
a=list(map(int,input().split()))
plus=[a[i] for i in range(n) if a[i]>=0]
l_plus=len(plus)
minus=[a[i] for i in range(n) if a[i]<0]
l_minus=len(minus)
x_cal=[]
y_cal=[]
if n==2:
  a.sort()
  print(a[1]-a[0])
  print(a[0],a[1])
else:
  if plus!=[] and minus!=[]:
    if l_plus>1:
      x_cal.append(minus[0])
    for j in range(1,l_plus-1):
      x_cal.append(x_cal[-1]-plus[j])
    for k in range(1,l_plus):
      y_cal.append(plus[k])
    if l_plus>1:
      y_last=x_cal[-1]-y_cal[-1]
    else:
      y_last=minus[0]
    x_cal.append(plus[0])
    for j in range(1,l_minus):
      x_cal.append(x_cal[-1]-minus[j])
    for k in range(1,l_minus):
      y_cal.append(minus[k])
    y_cal.append(y_last)
    print(x_cal[-1]-y_cal[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  elif minus==[]:
    a.sort()
    print(sum(a)-2*a[0])
    x_cal.append(a[0])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    y_cal.append(x_cal[-1]-y_cal[-1])
    x_cal.append(a[-1])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])
  else:
    a.sort()
    print(a[-1]*2-sum(a))
    x_cal.append(a[-1])
    for ij in range(1,n-2):
      x_cal.append(x_cal[-1]-a[ij])
    for jj in range(0,n-2):
      y_cal.append(a[jj+1])
    x_cal.append(x_cal[-1]-y_cal[-1])
    y_cal.append(a[0])
    for ii in range(n-1):
      print(x_cal[ii],y_cal[ii])