import java.util

object Main {
  def main(args: Array[String]): Unit = {
    val in = io.Source.fromInputStream(System.in).getLines()
    val N = in.next().toInt
    val A = in.next().split(' ') map (_.toInt)
    val B = in.next().split(' ') map (_.toInt)
    val C = in.next().split(' ') map (_.toInt)
    System.out.println(solve(N, A, B, C))
  }

  def solve(N: Int, A: Array[Int], B: Array[Int], C: Array[Int]): Long = {
    util.Arrays.sort(A)
    util.Arrays.sort(C)

    var r: Long = 0
    for {
      i <- B.indices
      ai = upperBound(A, B(i) - 1)
      ci = lowerBound(C, B(i) + 1)
      if ai != -1 && ci != -1
    } {
      r += upperBound(A, B(i) - 1).toLong * (N - lowerBound(C, B(i) + 1)).toLong
    }
    r
  }

  def lowerBound(a: Array[Int], x: Int): Int = {
    def step(from: Int, to: Int): Int = {
      if (from == to) from
      else {
        val i = from + (to - from) / 2
        if (x <= a(i)) step(from, i)
        else step(i + 1, to)
      }
    }
    step(0, a.length)
  }

  def upperBound(a: Array[Int], x: Int): Int = {
    def step(from: Int, to: Int): Int = {
      if (from == to) from
      else {
        val i = from + (to - from) / 2
        if (x < a(i)) step(from, i)
        else step(i + 1, to)
      }
    }
    step(0, a.length)
  }
}
