fun main(args: Array<String>) {
    fun readSortedLongList() = readLine()!!
            .split(" ")
            .map { it.toLong() }
            .sorted()

    val n = readLine()!!.toLong()
    val a = readSortedLongList()
    val b = readSortedLongList()
    val c = readSortedLongList()
    var count = 0L

    /**
     * 要素以上の左端
     */
    fun List<Long>.lowerBound(num: Long): Int {
        var low = -1
        var high = this.size
        while (high - low > 1) {
            val mid = low + (high - low) / 2
            if (this[mid] >= num) high = mid
            else low = mid
        }
        return high
    }

    /**
     * 要素より大きいやつの左端
     */
    fun List<Long>.upperBound(num: Long): Int {
        var low = -1
        var high = this.size
        while (high - low > 1) {
            val mid = low + (high - low) / 2
            if (this[mid] > num) high = mid
            else low = mid
        }
        return high
    }

    b.forEach {
        val up = a.lowerBound(it).toLong()
        val down = n - c.upperBound(it).toLong()
        count += up * down
    }

    println(count)
}