fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val an = readLine()!!.split(" ").map(String::toInt).sorted()
    val bn = readLine()!!.split(" ").map(String::toInt).sorted()
    val cn = readLine()!!.split(" ").map(String::toInt).sorted()

//    an.joinToString(",").let(::println)
//    bn.joinToString(",").let(::println)
//    cn.joinToString(",").let(::println)

    fun lowerBound(list: List<Int>, key: Int): Int {
        var left = -1
        var right = list.size

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

    }


    /**
     * key より大きい値の中から最小の index を返す
     * 該当するものがない場合、-1を返す
     */
    fun upperBound(list: List<Int>, key: Int): Int {

        var left = -1
        var right = list.size

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

    }


    var sum = 0L
    bn.forEach { b ->
        val a = lowerBound(an, b)
        val c = n - upperBound(cn, b)
//        println(b)
//        println(a)
//        println(c)
        sum += a.toLong() * c.toLong()
    }
    println(sum)
}

