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

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

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

	ans.writeln;
}