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();

    a ~= 10^^9 + 7;
    c ~= 10^^9 + 7;

    int l, r;

    long ans;

    foreach (i ; 0 .. n) {
        while (a[l] < b[i]) l++;
        while (c[r] <= b[i]) r++;
        ans += 1L * l * (n - r);
    }

    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);
        }
    }
}