"use strict"

//https://img.atcoder.jp/arc084/editorial.pdf

function main(input) {
  //binary search
  const bs = (arr, key) => {
    let left = 0
    let right = arr.length
    let mid = 0
    while (left < right) {
      mid = Math.floor((left + right) / 2)
      //////
      if (arr[mid] == key && mid < arr.length) {
        return arr.length - (mid + 1)
      } else if (mid == 0 && arr[mid] > key) {
        return arr.length - mid
      } else if (mid == 0 && arr[mid + 1] > key) {
        return arr.length - (mid + 1) // 残りの数（keyよりお大きい数の数）を
      } else if (arr[mid] > key && arr[mid - 1] < key) {
        return arr.length - mid // 残りの数（keyよりお大きい数の数）を
        //////////
      } else if (key < arr[mid]) {
        right = mid
      } else {
        left = mid + 1
      }
    }
    return false // not found
  }
  // end of bs

  input = input.split(/\n/).map(v =>
    v
      .split(" ")
      .map(v => ~~v)
      .sort((a, b) => a - b)
  )
  const n = input[0][0]
  const items = input.slice(1, input.length)

  let ans = 0
  let tmp2 = []
  let tmp = []

  for (let i1 = 0; i1 < n; i1++) {
    tmp[i1] = bs(items[1], items[0][i1])
  }
  for (let i2 = 0; i2 < n; i2++) {
    tmp2[i2] = bs(items[2], items[1][i2])
  }

  tmp2.reverse()
  for (let i = 0; i < tmp.length; i++) {
    ans += tmp2.slice(0, tmp[i]).reduce((a, b) => a + b)
  }
  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))