import java.util.Collections

fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    val topList = mutableListOf<Int>()
    val middleList = mutableListOf<Int>()
    val bottomList = mutableListOf<Int>()
    
    for (a in readInputLine().split(" ").map { it.toInt() }) {
        topList.add(a)
    }
    topList.sort()
    for (b in readInputLine().split(" ").map { it.toInt() }) {
        middleList.add(b)
    }
    for (c in readInputLine().split(" ").map { it.toInt() }) {
        bottomList.add(c)
    }
    bottomList.sort()

    var ans = 0L
    
    for (middle in middleList) {
        ans += (lowerBound(topList, middle)).toLong() * (n - upperBound(bottomList, middle)).toLong()
    }

    println(ans)
}
 
fun readInputLine(): String {
    return readLine()!!
}

// value以上の数値が現れる最初のインデックスを返す
fun <T: Comparable<T>> lowerBound(list: List<T>, value: T): Int {
    return Collections.binarySearch(list, value, {x, y -> if (x >= y) 1 else -1}).inv()
}

// valueより大きい数値が現れる最初のインデックスを返す
fun <T: Comparable<T>> upperBound(list: List<T>, value: T): Int {
    return Collections.binarySearch(list, value, {x, y -> if (x > y) 1 else -1}).inv()
}
