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(_.toInt).sorted
  
  val ans = b./:(0)((acc,e) => {
    val ap = binarySearch(a,e)
    val ac = if(ap >= 0) ap else ~ap

    val cp = binarySearch(c,e)
    val cc = if(cp >=0) n -cp -1 else n - ~cp

    acc + ac * cc
  })

  println(ans)
}