fun main(args: Array<String>) = p20()

fun p20() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }.toLongArray().sortedArray()
    val bList = readLine()!!.split(' ').map { it.toLong() }.toLongArray().sortedArray()
    val cList = readLine()!!.split(' ').map { it.toLong() }.toLongArray().sortedArray()

    var answer = 0L

    fun lowerBound(list: LongArray, key: Long): Int {
        var ng = -1
        var ok = list.size

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

    for (b in bList) {
        answer += lowerBound(aList, b).toLong() * (n - lowerBound(cList, b + 1))
    }

    println(answer)
}
