import java.io.{BufferedReader, InputStreamReader}
import java.util.Arrays.binarySearch
import java.util

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val n = in.readLine.toInt
  val a, b, c = in.readLine.split(" ").map(_.toLong)

  util.Arrays.sort(a)
  util.Arrays.sort(b)
  util.Arrays.sort(c)
  
  val ans = {
      var posA = 0
      var posC = 0

      def findA(tar:Long):Int = {
        val pa = binarySearch(a, posA, n, tar - 1)
        posA = if(pa > -1) pa else ~pa
        while(posA < n && a(posA) < tar) posA += 1
        posA
      }
      def findC(tar:Long):Int = {
        val pc = binarySearch(c, posC, n, tar - 1)
        posC = if(pc > -1) pc else ~pc
        while(posC < n && c(posC) <= tar) posC += 1
        posC
      }

      b./:(0L)((acc,e) => {
        val ac = findA(e)
        val cc = n - findC(e)

        acc +  ac.toLong * cc.toLong
      })
    }

  println(ans)
}