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

void main() {
	int N = readln.chomp.to!int;
	auto A = readln.chomp.split.to!(long[]).sort!"a < b",
               B = readln.chomp.split.to!(long[]).sort!"a < b",
	       C = readln.chomp.split.to!(long[]).sort!"a < b";

	long ans = 0;
	foreach (b; B)
           ans += A.lowerBound(b).length * C.upperBound(b).length;

	ans.writeln;
}