import std.stdio;
import std.string;
import std.conv;
import std.bigint;
import std.typecons;
import std.algorithm;
import std.array;
import std.math;
import std.range;
 
void main() {
    auto N = readln.chomp.to!int;
    auto A = sort(readln.split.to!(ulong[]));
    auto B = sort(readln.split.to!(ulong[]));
    auto C = sort(readln.split.to!(ulong[]));
    writeln(sum(B.map!(b => A.lowerBound(b).length * C.upperBound(b).length)));
}
