output_description: Print the number of different altars that Ringo can build.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 ... A_N
      B_1 ... B_N
      C_1 ... C_N
attempt: def lower_elements(A, b):
      lower_bound = -1
      upper_bound = len(A)
      while upper_bound - lower_bound > 1:  # ア
          middle = (lower_bound + upper_bound) // 2
          if A[middle] < b:  # イ
              lower_bound = middle
          else:
              upper_bound = middle
      return lower_bound + 1  # ウ upper_boundでも可
  
  
  def upper_elements(C, b):
      lower_bound = -1
      upper_bound = len(C)
      while upper_bound - lower_bound > 1:  # ア
          middle = (lower_bound + upper_bound) // 2
          if C[middle] <= b:
              lower_bound = middle
          else:
              upper_bound = middle
      return len(C) - upper_bound
  
  
  def answer(N: int, A: list, B: list, C: list):
      assert N == len(A) == len(B) == len(C)
      A.sort()
      B.sort()
      C.sort()
      count = 0
      for b in B:
          count += lower_elements(A, b) * upper_elements(C, b)
      return count
  
  
  def snuke_festival():
      N = int(input())
      A = list(map(int, input().split()))
      B = list(map(int, input().split()))
      C = list(map(int, input().split()))
      print(str(answer(N, A, B, C)) + '¥n')
  
  
  if __name__ == '__main__':
problem_description: Statement
  
  The season for Snuke Festival has come again this year. First of all, Ringo
  will perform a ritual to summon Snuke. For the ritual, he needs an altar,
  which consists of three parts, one in each of the three categories: upper,
  middle and lower.
  
  He has N parts for each of the three categories. The size of the i-th upper
  part is A_i, the size of the i-th middle part is B_i, and the size of the i-th
  lower part is C_i.
  
  To build an altar, the size of the middle part must be strictly greater than
  that of the upper part, and the size of the lower part must be strictly
  greater than that of the middle part. On the other hand, any three parts that
  satisfy these conditions can be combined to form an altar.
  
  How many different altars can Ringo build? Here, two altars are considered
  different when at least one of the three parts used is different.
samples: [{"input": "2\n    1 5\n    2 4\n    3 6", "output": "3\n    \n\nThe following three altars can be built:\n\n  * Upper: 1-st part, Middle: 1-st part, Lower: 1-st part\n  * Upper: 1-st part, Middle: 1-st part, Lower: 2-nd part\n  * Upper: 1-st part, Middle: 2-nd part, Lower: 2-nd part\n\n* * *"}, {"input": "3\n    1 1 1\n    2 2 2\n    3 3 3", "output": "27\n    \n\n* * *"}, {"input": "6\n    3 14 159 2 6 53\n    58 9 79 323 84 6\n    2643 383 2 79 50 288", "output": "87"}]