import scala.io.StdIn

import java.util.Arrays.binarySearch

object Main extends App {
  val n = StdIn.readInt
  val a, b, c = StdIn.readLine.split(" ").map(_.toLong).sorted
  
  val ans = {
      var posA = 0
      var posC = 0
      def findA(tar:Long):Int = {
        while(posA < n && a(posA) < tar) posA += 1
        posA
      }
      def findC(tar:Long):Int = {
        while(posC < n && c(posC) <= tar) posC += 1
        posC
      }

      b./:(0L)((acc,e) => {
        val ac = findA(e)
        val cc = n - findC(e)

        acc +  ac.toLong * cc.toLong
      })
    }

  println(ans)
}