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[])).enumerate.assumeSorted;
    auto B = sort(readln.split.to!(ulong[])).enumerate.assumeSorted;
    auto C = sort(readln.split.to!(ulong[])).enumerate.assumeSorted;
    //あるBを選んだときのCの数を数える
    auto count = B.map!(b => N - C.find!(c => b.value < c.value)[0].index).array;
    foreach_reverse(i; 0..N-1) {
        count[i] += count[i+1];
    }
    writeln(sum(A.map!(a => B.find!(b => a.value < b.value)).filter!(a => a.length > 0).map!(a => count[a[0].index])));
}
