import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto a = readln.split.to!(long[]);
  auto b = readln.split.to!(long[]);
  auto c = readln.split.to!(long[]);

  auto as = a.sort();
  auto bs = b.sort();
  auto cs = c.sort();

  auto bc = new long[](n);
  foreach (i; 0..n)
    bc[i] = cs.upperBound(bs[i]).length;

  foreach_reverse (i; 0..n-1)
    bc[i] += bc[i+1];

  auto ans = 0L;
  foreach (i; 0..n) {
    auto at = bs.upperBound(as[i]);
    if (!at.empty) {
      auto j = bs.length - bs.upperBound(as[i]).length;
      ans += bc[j];
    }
  }

  writeln(ans);
}
