fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val lists = (1..3).map { readLine()!!.split(" ").map { it.toLong() }.sorted() }
    val solve = Solve(lists[0], lists[1], lists[2])
    println(solve.getAns())
}

class Solve(val aList:List<Long>, val bList:List<Long>, val cList:List<Long>) {
    fun getAns():Long {
        for(i in cList.indices) {
            getC(i)
        }
        return cList.indices.map { getC(it) }.sum()
    }
    val countCDic = mutableMapOf<Int, Int>()
    val totalCDic = mutableMapOf<Int, Long>()
    val countBDic = mutableMapOf<Int, Int>()
    fun getC(index:Int):Long {
        totalCDic[index]?.let { return it }
        val start = countCDic[index-1]?:0
        var total = totalCDic[index-1]?:0
        var count = start
        for(i in (start..bList.lastIndex)) {
            if(bList[i] >= cList[index]) {
                break
            }
            count = i + 1
            total += getB(i)
        }
        countCDic[index] = count
        totalCDic[index] = total
        return total
    }
    fun getB(index:Int):Int {
        val start = countBDic[index-1]?:0
        var cnt = start
        for(i in (start..aList.lastIndex)) {
            if(aList[i] >= bList[index]) {
                break
            }
            cnt = i + 1
        }
        countBDic[index] = cnt
        return cnt
    }
}