void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);
    long[] b = readln.split.to!(long[]);
    long[] c = readln.split.to!(long[]);

    a.sort!"a < b";
    c.sort!"a < b";
    auto aa = a.assumeSorted;
    auto ca = c.assumeSorted;
    long result;
    foreach (x; b)
    {
        long aal = aa.lowerBound(x).length;
        long cal = ca.upperBound(x).length;
        result += aal * cal;
    }

    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;