
object Main {
  def main(args: Array[String]) {
    def compare(a: => Long, b: =>  Long): Boolean = a <= b
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    var A: Array[Long] = Array.fill(N)(0)
    for (i <- 0 until N) A(i) = sc.nextLong
    A = A.sorted
    var B: Array[Long] = Array.fill(N)(0)
    for (i <- 0 until N) B(i) = sc.nextLong
    B = B.sorted
    var C: Array[Long] = Array.fill(N)(0)
    for (i <- 0 until N) C(i) = sc.nextLong
    C = C.sorted
    var all = 0
    var BC = Array.fill(N)(0) //B(i)に置ける全部の個数
    var k = 0
    for (j <- 0 until N) {
      while (k < N && compare(C(k), B(j))) {
        k = k + 1
      }
      if (k < N) {
        BC(j) = N - k //B(i) > C(j)のCの数をまず入れる
      }
    }
    if (N > 1) {
      for (j <- N - 2 to 0 by -1) {
        BC(j) = BC(j) + BC(j + 1) //B(i) > C(j)の全部の個数
      }
    }
    var j = 0
    k = 0
    for (i <- 0 until N) {
        while (j < N && compare(B(j),A(i))) {
          j = j + 1
        }
        if (j < N) {
          all = all + BC(j)
        }
    }
    println(all)
  }
}