fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    val B = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    val C = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    A.sort()
    B.sort()
    C.sort()


    fun lowerBound(list: IntArray, trg: Int) : Int {
        var ok = list.size
        var ng = -1

        while (Math.abs(ok - ng) > 1) {
            val mid = (ok + ng) / 2
            if (list[mid] >= trg) {
                ok = mid
            } else {
                ng = mid
            }
        }
        return ok
    }

    val bToC = IntArray(N)

    for (i in 0 until N) {
        val b = B[i]
        val index = lowerBound(C, b + 1)
        val counts = N - index
        bToC[i] = counts
    }
    val cumBtoC = LongArray(N + 1)
    cumBtoC[0] = 0
    for (i in 0 until N) {
        cumBtoC[i+1] = cumBtoC[i] + bToC[i]
    }

    var answer = 0L
    for (i in 0 until N) {
        val a = A[i]
        val index = lowerBound(B, a + 1)
        answer += (cumBtoC[N] - cumBtoC[index])
    }
    println(answer)
}
