fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }.sorted()
    val b = readLine()!!.split(" ").map { it.toLong() }.sorted()
    val c = readLine()!!.split(" ").map { it.toLong() }.sorted()

    b.map {
        a.lowerBound(it).toLong() * (n-c.lowerBound(it+1)).toLong()
    }.sum().let { println(it) }

}

//ソート済みのListに対して、log(size)回の比較でelementより(真に)小さい要素の個数(element以上の要素が初めて現れるindex)を返す。
fun <T : Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int = 0, toIndex: Int = size): Int {
    var low = fromIndex
    var high = toIndex

    while (low < high) {
        val mid = (low + high).ushr(1)
        val cmp = get(mid).compareTo(element)

        if (cmp < 0)
            low = mid + 1
        else //(cmp >= 0)
            high = mid
    }
    return low
}