import java.util.*

fun main(args: Array<String>) {
    val upper = object : Comparator<Long> {
        override fun compare(o1: Long?, o2: Long?): Int {
            return if (o1!! == o2!!) -1 else if (o1 < o2) -1 else 1
        }
    }

    val lower = object : Comparator<Long> {
        override fun compare(o1: Long?, o2: Long?): Int {
            return if (o1!! == o2!!) 1 else if (o1 < o2) -1 else 1
        }
    }
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = LongArray(n) { sc.nextLong() }.sorted()
    val b = LongArray(n) { sc.nextLong() }.sorted()
    val c = LongArray(n) { sc.nextLong() }.sorted()

    val ret = b
        .map { bv ->
            val ac = a.binarySearch(bv, lower).let { i -> -(i + 1) }
            val cc = c.binarySearch(bv, upper).let { i -> n - (-(i + 1)) }

            cc.toLong() * ac.toLong()
        }
        .sum()

    println(ret)
}