fun <T : Comparable<T>> List<T>.insertPosition(e: T): Int {
    var low = 0
    var high = size
    while (low < high) {
        val middle = (low + high) / 2
        if (this[middle] < e) {
            low = middle + 1
        } else {
            high = middle
        }
    }
    return low
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(' ').map(String::toInt).sorted()
    val bb = readLine()!!.split(' ').map(String::toInt)
    val cc = readLine()!!.split(' ').map(String::toInt).sorted()
    var sum = 0L
    for (b in bb) {
        val posA = aa.insertPosition(b)
        val posC = cc.insertPosition(b + 1)
        sum += posA.toLong() * (n - posC).toLong()
    }
    println(sum)
}
