import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt

  def binarySearch(a: Array[Int], t: Int): Int = {
    val max = a.length

    var l = -1
    var r = a.length

    while (r - l > 1) {
      //val mid = l + (r - l) / 2
      val mid = (l + r) / 2
      //println(s"$r $mid $l")
      if (a(mid) < t) l = mid
      else r = mid
    }

    //println(a.toList)
    //println(s"$t -> $r")
    r
  }

  val ra = StdIn.readLine().split(' ').map(_.toInt).sorted
  val rb = StdIn.readLine().split(' ').map(_.toInt).sorted
  val rc = StdIn.readLine().split(' ').map(_.toInt).sorted
  //val rc = StdIn.readLine().split(' ').map(_.toInt * -1).sorted
  var count = rb.foldLeft(0L) { (acc, b) =>
    val r1 = binarySearch(ra, b)
    //val r2 = binarySearch(rc, -1 * b)
    val r2 = n - binarySearch(rc, b + 1)

    //println(r1 * r2)
    acc + r1 * r2
  }

  println(count)

}