import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val top = readLine.split(" ").map(_.toInt).sorted
  val middle = readLine.split(" ").map(_.toInt)
  val bottom = readLine.split(" ").map(_.toInt).sorted

  var count = 0

  for (m <- middle) {
    val a = top.count(e => e < m)
    val b = bottom.count(e => m < e)
    count += a * b
  }

  println(count)

}