Buggy python submission (verdict: Runtime Error):
def simulateBoard(posNums, negNums):
  P, N = len(posNums), len(negNums)
  out_str = ""
  
  if P == 0:
    negNums.sort(reverse=True)
    
    num1 = negNums[0]
    num2 = negNums.pop()
    
    last_pos = num1 - num2
    negNums = negNums[1:]
    print(abs(sum(negNums)) + last_pos)
    print(num1, ' ', num2) 
    last_neg = negNums.pop() 
    
    while len(negNums) != 0:
      cur_neg = negNums.pop()
      cur_diff = last_pos - cur_neg
      print(last_pos, ' ', cur_neg, ' ')
      last_pos = cur_diff
   	
    cur_diff = last_pos - last_neg
    print(last_pos, ' ', last_neg, ' ')
    
  
  elif N == 0:
    posNums.sort()
    
    num1 = posNums[0]
    num2 = posNums.pop()
    
    last_neg = num1 - num2
    posNums = posNums[1:]
    print(abs(last_neg) + sum(posNums))
    print(num1, ' ', num2)
    last_pos = posNums.pop()

    while len(posNums) != 0:
      cur_pos = posNums.pop()
      cur_diff = last_neg - cur_pos
      print(last_neg, ' ', cur_pos, ' ')
      last_neg = cur_diff
   	
    cur_diff = last_pos - last_neg
    print(last_pos, ' ', last_neg, ' ')
    
    
    
  
  #if N == 0:
    #last_neg = negNums.pop()
    
    #while len(negNums) != 0:
      #cur_neg = negNums.pop()
      #cur_diff = last_pos - cur_neg
      #print(last_pos, ' ', cur_neg, ' ')
      #last_pos = cur_diff
    
  
  elif P>=1 and N>=1:
    print(abs(sum(negNums)) + sum(posNums)) 
    
    last_pos = posNums.pop()
    last_neg = negNums.pop()
    
    while len(negNums) != 0:
      cur_neg = negNums.pop()
      cur_diff = last_pos - cur_neg
      print(last_pos, ' ', cur_neg, ' ')
      last_pos = cur_diff
    
    while len(posNums) != 0:
      cur_pos = posNums.pop()
      cur_diff = last_neg - cur_pos
      print(last_neg, ' ', cur_pos, ' ')
      last_neg = cur_diff
   	
    cur_diff = last_pos - last_neg
    print(last_pos, ' ', last_neg, ' ')

N = int(input())
nums = input().split()
nums = [int(i) for i in nums]
pos_nums = []
neg_nums = []

for num in nums:
  if num >= 0: pos_nums.append(num)
  else: neg_nums.append(num)
    
simulateBoard(pos_nums, neg_nums)




Fixed submission:
def simulateBoard(posNums, negNums):
  P, N = len(posNums), len(negNums)
  out_str = ""
  
  if P == 0 and N == 2:
    num1 = max(negNums)
    num2 = min(negNums)
    print(num1 - num2)
    print(num1, ' ', num2)
  elif N==0 and P==2:
    num1, num2 = max(posNums), min(posNums)
    print(num1 - num2)
    print(num1, ' ', num2)
  elif P == 0:
    negNums.sort(reverse=True)
    
    num1 = negNums[0]
    num2 = negNums.pop()
    
    last_pos = num1 - num2
    negNums = negNums[1:]
    print(abs(sum(negNums)) + last_pos)
    print(num1, ' ', num2) 
    last_neg = negNums.pop() 
    
    while len(negNums) != 0:
      cur_neg = negNums.pop()
      cur_diff = last_pos - cur_neg
      print(last_pos, ' ', cur_neg, ' ')
      last_pos = cur_diff
   	
    cur_diff = last_pos - last_neg
    print(last_pos, ' ', last_neg, ' ')
    
  
  elif N == 0:
    posNums.sort()
    
    num1 = posNums[0]
    num2 = posNums.pop()
    
    last_neg = num1 - num2
    posNums = posNums[1:]
    print(abs(last_neg) + sum(posNums))
    print(num1, ' ', num2)
    last_pos = posNums.pop()

    while len(posNums) != 0:
      cur_pos = posNums.pop()
      cur_diff = last_neg - cur_pos
      print(last_neg, ' ', cur_pos, ' ')
      last_neg = cur_diff
   	
    cur_diff = last_pos - last_neg
    print(last_pos, ' ', last_neg, ' ')
    
    
    
  
  #if N == 0:
    #last_neg = negNums.pop()
    
    #while len(negNums) != 0:
      #cur_neg = negNums.pop()
      #cur_diff = last_pos - cur_neg
      #print(last_pos, ' ', cur_neg, ' ')
      #last_pos = cur_diff
    
  
  elif P>=1 and N>=1:
    print(abs(sum(negNums)) + sum(posNums)) 
    
    last_pos = posNums.pop()
    last_neg = negNums.pop()
    
    while len(negNums) != 0:
      cur_neg = negNums.pop()
      cur_diff = last_pos - cur_neg
      print(last_pos, ' ', cur_neg, ' ')
      last_pos = cur_diff
    
    while len(posNums) != 0:
      cur_pos = posNums.pop()
      cur_diff = last_neg - cur_pos
      print(last_neg, ' ', cur_pos, ' ')
      last_neg = cur_diff
   	
    cur_diff = last_pos - last_neg
    print(last_pos, ' ', last_neg, ' ')

N = int(input())
nums = input().split()
#print(nums)
nums = [int(i) for i in nums]
pos_nums = []
neg_nums = []

for num in nums:
  if num >= 0: pos_nums.append(num)
  else: neg_nums.append(num)
    
simulateBoard(pos_nums, neg_nums)