import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
  int n = readln.chomp.to!int;
  int[] a = readln.chomp.split.map!(to!int).array;
  a.sort;
  int[] b = readln.chomp.split.map!(to!int).array;
  b.sort;
  int[] c = readln.chomp.split.map!(to!int).array;
  c.sort;
  ulong[ulong] memo;
  foreach (i, v; b) {
    memo[i] = find!"a > b"(c, v).length;
  }
  memo[n] = 0;
  foreach_reverse (i; 0..n) {
    memo[i] += memo[i + 1];
  }
  ulong cnt = 0;
  foreach (v; a) {
    // use v
    ulong len = find!"a > b"(b, v).length;
    cnt += memo[n - len];
    /+
    foreach (w; find!"a > b"(b, v)) {
      // use w
      cnt += find!"a > b"(c, w).length;
    }
    +/
  }
  cnt.writeln;
}
