fun main() {
    class BinSearch<T: Comparable<T>> (inp:List<T>) {
        val li = inp.sorted()

        fun find(tar:T, opt: String="default"):Int{
            var l=0
            var r=this.li.size-1
            var ans=-1
            var tmp=-1
            while (opt=="default" && l<=r){
                tmp=(l+r)/2
                if (this.li[tmp]<tar) {l=tmp+1}
                if (tar<this.li[tmp]) {r=tmp-1}
                if (this.li[tmp]==tar) {break}
            }
            while (opt=="upper" && l<=r){
                tmp=(l+r)/2
                if (this.li[tmp]<tar) {l=tmp+1}
                if (tar<=this.li[tmp]) {r=tmp-1}
            }
            while (opt=="lower" && l<=r){
                tmp=(l+r)/2
                if (this.li[tmp]<=tar) {l=tmp+1}
                if (tar<this.li[tmp]) {r=tmp-1}
            }
            when {
                this.li[tmp]==tar->ans=tmp
                this.li[tmp]<tar->{
                    when(opt){
                        "lower"->ans=tmp
                        "upper"->ans=tmp+1
                    }
                }
                this.li[tmp]>tar->{
                    when(opt){
                        "upper"->ans=tmp
                        "lower"->ans=tmp-1
                    }
                }
            }
            return ans
        }
    }
    var n= readLine()!!.toLong()
    var a=BinSearch(readLine()!!.split(" ").map { it.toLong() }.sorted())
    var b=BinSearch(readLine()!!.split(" ").map { it.toLong() }.sorted())
    var c=BinSearch(readLine()!!.split(" ").map { it.toLong() }.sorted())
    var ans:Long=0
    for (i in b.li){
        var ind1=a.find(i-1, "lower")
        var ind2=c.find(i+1, "upper")
        ans+=(ind1+1)*(n-ind2)

    }
    println(ans)
}