import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val n = sc.nextInt()
        val a = Array(n) { sc.nextInt() }
        val b = Array(n) { sc.nextInt() }
        val c = Array(n) { sc.nextInt() }
        a.sort()
        b.sort()
        c.sort()

        val ar = Array(n + 1) { 0L }

        for (i in 0 until n) {
            var ng = n
            var ok = -1
            while (ng - ok > 1) {
                val mid = (ok + ng) / 2
                if (a[mid] < b[i]) {
                    ok = mid
                } else {
                    ng = mid
                }
            }
            ar[i + 1] = ar[i] + ng
        }
        var ans = 0L
        for (i in 0 until n) {
            var ng = n
            var ok = -1
            while (ng - ok > 1) {
                val mid = (ok + ng) / 2
                if (b[mid] < c[i]) {
                    ok = mid
                } else {
                    ng = mid
                }
            }
            ans += ar[ng]
        }

        println(ans)
    }
}

class SegmentTree<T>(private val op: (T, T) -> T, private val id: T) {
    companion object {
        const val size = 1 shl 17
    }

    @Suppress("UNCHECKED_CAST")
    private val array = Array<Any?>(size * 2) { id } as Array<T>

    operator fun get(i: Int) = array[i + size]
    operator fun set(i: Int, n: T) = update(i, n)

    fun update(i: Int, n: T) {
        var index = i + size
        array[index] = n
        while (index > 1) {
            index /= 2
            array[index] = op(array[index * 2], array[index * 2 + 1])
        }
    }

    private fun query(left: Int, right: Int, k: Int, l: Int, r: Int): T {
        if (left <= l && r <= right) {
            return array[k]
        }

        if (r <= left || right <= l) {
            return id
        }

        return op(query(left, right, k * 2, l, (l + r) / 2), query(left, right, k * 2 + 1, (l + r) / 2, r))
    }

    fun query(left: Int, right: Int) = query(left, right, 1, 0, size)
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 46040