import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;

void main() {
  long N = readln.chomp.to!int;
  auto A = readln.chomp.split.map!(to!long).array;
  auto B = readln.chomp.split.map!(to!long).array;
  auto C = readln.chomp.split.map!(to!long).array;

  sort!("a < b")(A);
  sort!("a < b")(B);
  sort!("a < b")(C);

  long ans;

  foreach(b; B) {
    long a, c, ok, ng, m;
    ng = N;

    if (A[$ - 1] < b) {
      a = N;
    }
    else if (A[0] < b) {
      while ((ng - ok) > 1) {
        m = (ok + ng) / 2;

        if (A[m] < b) {
          ok = m;
        }
        else {
          ng = m;
        }
      }
      a = ok + 1;
    }

    ok = N, ng = 0;

    if (C[0] > b) {
      c = N;
    }
    else if (C[$ - 1] > b) {
      while ((ok - ng) > 1) {
        m = (ok + ng) / 2;

        if (C[m] <= b) {
          ng = m;
        }
        else {
          ok = m;
        }
      }
      c = (N - ok);
    }

    ans += a * c;
  }

  ans.writeln;
}