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

    var result = loop(0, 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).sorted

  var count = rb.foldLeft(0L) { (acc, b) =>
    val r1 = binarySearch(ra, b)
    val rt = binarySearch(rc, b)
    val r2 = rc.length - (if(rc(rt) == b) rt + 1 else rt)

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

  println(count)

}