import scala.io.StdIn

object Main extends App {

  //
  // std in
  //

  val n = StdIn.readInt()
  val as = StdIn.readLine().split(" ").map(_.toLong).sorted
  val bs = StdIn.readLine().split(" ").map(_.toLong).sorted
  val cs = StdIn.readLine().split(" ").map(_.toLong).sorted

  //
  // main
  //

  println(
    bs.map { b => countUpper(cs, b) * countLower(as, b) }.sum
  )

  //
  // functions
  //

  def countUpper(xs: Array[Long], x: Long): Long = xs.length - upperBound(xs, x)

  def countLower(xs: Array[Long], x: Long): Long = lowerBound(xs, x)

  //
  // libs
  //

  def lowerBound(xs: Array[Long], x: Long): Int = {
    var lSide: Int = -1
    var rSide: Int = xs.length

    while (rSide - lSide > 1) {
      val mid = lSide + (rSide - lSide) / 2

      if (xs(mid) >= x) rSide = mid
      else lSide = mid
    }

    rSide
  }

  def upperBound(xs: Array[Long], x: Long): Int = {
    var lSide: Int = -1
    var rSide: Int = xs.length

    while (rSide - lSide > 1) {
      val mid = lSide + (rSide - lSide) / 2

      if (xs(mid) > x) rSide = mid
      else lSide = mid
    }

    rSide
  }
}
