import scala.annotation.tailrec

object Main extends App {
    val N: Int = io.StdIn.readInt() - 1
    val A: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt).sorted
    val B: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt).sorted
    val C: Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt).sorted

  val result = B.foldLeft(BigInt(0))((count, b) => {
    getLesserCount(b, 0, A) * getLargerCount(b, 0, C) + count
  })

  println(result)

  @tailrec
  private def getLargerCount(compared: BigInt, count: BigInt, li: Seq[Int]): BigInt = {
    if (li.isEmpty) {
      count
    } else if (li.length == 1) {
      if (compared < li.head) count + 1 else count
    } else {
      val (left, right) = li.splitAt(li.length / 2)
      if (compared < right.head) {
        getLargerCount(compared, count + right.length, left)
      } else {
        getLargerCount(compared, count, right)
      }
    }
  }

  @tailrec
  private def getLesserCount(compared: BigInt, count: BigInt, li: Seq[Int]): BigInt = {
    if (li.isEmpty) {
      count
    } else if (li.length == 1) {
      if (li.head < compared) count + 1 else count
    } else {
      val (left, right) = li.splitAt(li.length / 2)
      if (left.last < compared)
        getLesserCount(compared, count + left.length, right)
      else
        getLesserCount(compared, count, left)
    }
  }
}
