import scala.io.{StdIn => in}
import annotation.tailrec

object Main extends App {
  val n = in.readInt
  val a = 0 +: in.readLine.split(" ").map(_.toInt).sorted
  val b = in.readLine.split(" ").map(_.toInt).sorted
  val c = 0 +: in.readLine.split(" ").map(_.toInt).sorted

  val ans = b./:(0L) { (acc, i) =>
    val ia = binarySearch(a, i, false)
    val ic = n - binarySearch(c, i, true)
    // println(ia, ic)
    acc + ia.toLong * ic.toLong
  }
  
  println(ans)

  def binarySearch(arr: Array[Int], key: Int, isUpper: Boolean): Int = {
    var left = 0
    var right = arr.size

    val evalute = (idx: Int, key: Int) => {
      if(isUpper) arr(idx) <= key else arr(idx) < key
    }

    @tailrec
    def loop(left:Int, right:Int):Int = {
      if(right - left < 2) left
      else {
        val mid = (left + right) / 2
        if( evalute(mid, key) ) loop(mid,right)
        else loop(left, mid)
      }
    }
    loop(left, right)
  }
}