object Main {
  import scala.annotation.tailrec
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val an = Vector.fill(n)(sc.nextInt).sorted
    val bn = Vector.fill(n)(sc.nextInt).sorted
    val cn = Vector.fill(n)(sc.nextInt).sorted

    val count = an.map{ a =>
      lowerBounds(bn, a+1).map{ b =>
        lowerBounds(cn, b+1).length
      }.sum
    }.sum
    println(count)
  }

  def lowerBounds(seq: Seq[Int], target: Int): Seq[Int] = {
    @tailrec
    def go(target: Int, start: Int, end: Int): Seq[Int] = {
      val mid = ((end - start) / 2 + start)
      if (target <= seq(mid)) {
        if (end - start <= 1 || seq(mid - 1) < target) seq.drop(mid)
        else go(target, start, mid)
      } else {
        if (end - start <= 1 && target <= seq(mid + 1)) {
          seq.drop(end)
        }
        else if (end - start <= 1 && target > seq(mid + 1)) Seq[Int]()
        else if (target <= seq(mid + 1)) seq.drop(mid+1)
        else go(target, mid, end)
      }
    }
    go(target, 0, seq.length - 1)
  }
}
