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の数を数える
    ulong[] count = new ulong[N];
    foreach (i; 0..N) {
        auto b = B[i];
        auto t = C.find!(c => b.value < c.value)[0].index;
        count[i] = N-t;
    }
    ulong s = 0;
    foreach (i; 0..N) {
        auto a = A[i];
        s += sum(B.find!(b => a.value < b.value).map!(b => count[b.index]));
    }
    writeln(s);
}
