import java.util.concurrent.{ForkJoinPool, RecursiveTask}

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 pool = new ForkJoinPool()

  class AggregateTask(seq: Seq[Int]) extends RecursiveTask[BigInt] {
    override def compute(): BigInt = {
      val n = seq.length / 2
      if (n == 0) {
        seq match {
          case Seq() => n
          case Seq(n) => A.count(_ < n) * C.count(_ > n)
        }
      } else {
        val (left, right) = seq.splitAt(n)
        val leftTask = new AggregateTask(left)
        val rightTask = new AggregateTask(right)
        leftTask.fork()
        rightTask.fork()
        leftTask.join() + rightTask.join()
      }
    }
  }

  println(pool.invoke(new AggregateTask(B)))
}
