import java.io.PrintWriter import java.util.* import kotlin.math.* fun PrintWriter.solve() { val n = nextInt() val r = Array(n) { nextInt() } val g = Array(n) { nextInt() } val b = Array(n) { nextInt() } r.sort() g.sort() b.sort() val cnt = LongArray(6005) { 0 } for (v in r) { cnt[v]++ } for (i in 0 until 6000) { cnt[i + 1] += cnt[i] } var ans = 0L val cnt_g = LongArray(3005) { 0 } val cnt_b = LongArray(3005) { 0 } for (v in g) { cnt_g[v]++ } for (v in b) { cnt_b[v]++ } for (i in 1 until 3002) { for (j in 1 until 3002) { ans += cnt[i + j - 1] * cnt_g[i] * cnt_b[j] ans -= cnt[max(i, j) - 1] * cnt_g[i] * cnt_b[j] } } println(ans) } fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion