import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    int n;
    int[] a, b, c;

    scan(n);
    a = readln.split.to!(int[]);
    b = readln.split.to!(int[]);
    c = readln.split.to!(int[]);

    a.sort();
    b.sort();
    c.sort();

    debug {
        writeln(a);
        writeln(b);
        writeln(c);
    }

    auto d = new long[](n + 1);

    int j;

    foreach (i ; 0 .. n) {
        for (;j < n; j++) {
            if (b[i] < c[j]) {
                d[i] = n - j;
                break;
            }
        }
    }

    foreach_reverse (i ; 0 .. n) {
        d[i] += d[i + 1];
    }

    debug {
        writeln("d:", d);
    }

    j = 0;
    long ans;

    foreach (i ; 0 .. n) {
        for (;j < n; j++) {
            if (a[i] < b[j]) {
                writefln("i, j:%d %d", i, j);
                ans += d[j];
                break;
            }
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}