fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val n = readLine()?.toInt() ?: return
    val a = longList()
    val b = longList().sorted()
    val c = longList().sorted()
    val bc = Array(n + 1) { 0L }
    var t = 0L

    var s = 0L
    (n - 1).downTo(0).forEach {
        val bb = b[it]
        val u = c.upperBound(bb)
        s += n - u
        bc[it] = s
    }
    repeat(n) {
        val aa = a[it]
        val i = b.upperBound(aa)
        t += bc[i]
    }
    println(t.toString())
}

fun <T : Comparable<T>> List<T>.upperBound(e: T): Int {
    val index = binarySearch(e, Comparator { x, y -> if (x > y) 1 else -1 })
    return if (index >= 0) {
        index
    } else {
        -(index + 1)
    }
}

