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];
        if (b.value < C[0].value) {
            count[i] = N;
        } else if (b.value > C[N-1].value) {
            count[i] = 0;
        } else {
            size_t start = 0;
            size_t end = N-1;
            while (start+1 != end) {
                auto middle = (start + end) / 2;
                if (b.value < C[middle].value) {
                    end = middle;
                } else if (C[middle].value <= b.value){
                    start = middle;
                }
            }
            count[i] = N-end;
        }
    }
    foreach_reverse(i; 0..N-1) {
        count[i] += count[i+1];
    }
    ulong s = 0;
    foreach (i; 0..N) {
        auto a = A[i];
        size_t idx;
        if (a.value < B[0].value) {
            idx = 0;
        } else if (a.value > B[N-1].value) {
            continue;
        } else {
            size_t start = 0;
            size_t end = N-1;
            while (start+1 != end) {
                auto middle = (start + end) / 2;
                if (a.value < B[middle].value) {
                    end = middle;
                } else if (B[middle].value <= a.value){
                    start = middle;
                }
            }
            idx = end;
        }
        s += count[idx];
    }
    writeln(s);
}
