function Main(input) {
  input = input.trim().split("\n");
  var N = parseInt(input[0], 10);
  var A = input[1]
    .split(" ")
    .map((n) => parseInt(n, 10))
    .sort((a, b) => a - b);
  var B = input[2]
    .split(" ")
    .map((n) => parseInt(n, 10))
    .sort((a, b) => a - b);
  var C = input[3]
    .split(" ")
    .map((n) => parseInt(n, 10))
    .sort((a, b) => a - b);

  //２分探索 昇順である前提
  //mode="low"で求めたい数以下の数
  function serch2bu(list, num, mode) {
    var index = -1;
    var head = 0;
    var tail = list.length;
    if (mode == "low") {
      while (head <= tail) {
        var center = Math.floor((head + tail) / 2);
        var centerVal = list[center];

        if (centerVal < num) {
          head = center + 1;
        } else {
          tail = center - 1;
        }
      }
    } else if (mode == "high") {
      while (head <= tail) {
        var center = Math.floor((head + tail) / 2);
        var centerVal = list[center];

        if (centerVal <= num) {
          head = center + 1;
        } else {
          tail = center - 1;
        }
      }
    }
    return head;
  }
  var ans = 0;
  for (var i = 0; i < N; i++) {
    var a = serch2bu(A, B[i], "low");
    var b = N - serch2bu(C, B[i], "high");
    ans += a * b;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
