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
    
    def loop(l: Int, r: Int): Int = {
      if (r - l == 1 ) {
        r
      } else {
        val mid = l + (r - l) / 2
        //println(s"$r $mid $l")
        if (a(mid) < t) loop(mid, r)
        else loop(l, mid)
      }
    }

    var result = loop(-1, max)
    //println(a.toList)
    //println(s"$t -> $result")
    result
  }

  val ra = StdIn.readLine().split(' ').map(_.toInt).sorted
  val rb = 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)

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

  println(count)

}