import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    auto N = lread();
    auto A = aryread();
    auto B = aryread();
    auto C = aryread();
    // writeln(A);
    // writeln(B);
    // writeln(C);
    auto a = A.sort();
    auto b = B.sort();
    auto c = C.sort();
    // writeln(a);
    // writeln(b);
    // writeln(c);
    auto x = new long[](N);
    auto y = new long[](N);
    // writeln(x);

    foreach (i; 0 .. N)
    {
        long ok = -1;
        long ng = a.length;
        while (abs(ng - ok) > 1)
        {
            long mid = (ok + ng) / 2;
            if (a[mid] < b[i])
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }

        }
        // writeln("b[i]:", b[i]);
        // writeln("ok:", ok);
        // writeln("ng:", ng);
        // writeln("a[ok]:", a[ok]);
        x[i] = ok + 1;
        // writeln("x:", x);
    }
    foreach (i; 0 .. N)
    {
        long ok = b.length;
        long ng = -1;
        while (abs(ok - ng) > 1)
        {
            long mid = (ok + ng) / 2;
            if (c[mid] > b[i])
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        // writeln("b[i]:", b[i]);
        // writeln("ok:", ok);
        // writeln("ng:", ng);
        // writeln("c[ok]:", c[ok]);
        y[i] = b[ok .. $].length;
        // writeln("y:", y);

    }
    // writeln(x);
    // writeln(y);
    long ans;
    foreach (i; 0 .. N)
    {
        ans += x[i] * y[i];
    }
    // writeln("ans:", ans);
    writeln(ans);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
