import java.util.Comparator
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt().sorted()
    val B = listOfInt()
    val C = listOfInt().sorted()
    var ans = 0L
    for (b in B) {
        val a = A.lowerBound(b)
        val c = C.upperBound(b)
        ans += 1L * a * (N - c)
    }
    println(ans)
}
//lowerBound関数は指定した値以上の要素が最初に現れる位置
fun List<Int>.lowerBound(n: Int) = this.binarySearch(n, Comparator { x, y -> if (x.compareTo(y) >= 0) 1 else -1 }).inv()
//upperBound関数は指定した値より大きいの要素が最初に現れる位置
fun List<Int>.upperBound(n: Int) = this.binarySearch(n, Comparator { x, y -> if (x.compareTo(y) >  0) 1 else -1 }).inv()

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(d: Int = 0) = listOfString().map { Integer.parseInt(it) + d }
fun listOfLong() = listOfString().map(String::toLong)
