process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function compareNumber(a, b) {
    if (a < b) {
        return -1;
    }
    if (a > b) {
        return 1;
    }
    return 0;
}

function Main(input) {

    var n = parseInt(input[0], 10);

    var a = new Array(n);
    var astr = input[1].split(' ');
    for (var i = 0; i < n; i++) {
        a[i] = parseInt(astr[i], 10);
    }
    a.sort(compareNumber);

    var b = new Array(n);
    var bstr = input[2].split(' ');
    for (var i = 0; i < n; i++) {
        b[i] = parseInt(bstr[i], 10);
    }
    b.sort(compareNumber);

    var c = new Array(n);
    var cstr = input[3].split(' ');
    for (var i = 0; i < n; i++) {
        c[i] = parseInt(cstr[i], 10);
    }
    c.sort(compareNumber);


    var ans = 0;
    for (var i = 0; i < n; i++) {
        var anum = lower_bound(a, b[i]);
        var cnum = n - upper_bound(c, b[i]);
        ans += anum * cnum;
    }

    console.log(ans);

    return 0;
}

function lower_bound(array, target) {
    var min = 0;
    var max = array.length - 1;
    while (min <= max) {
        var middle = min + Math.floor((max - min) / 2);
        if (array[middle] < target) {
            min = middle + 1;
        }
        else {
            max = middle - 1;
        }
    }

    return min;
}

function upper_bound(array, target) {
    var min = 0;
    var max = array.length - 1;
    while (min <= max) {
        var middle = min + Math.floor((max - min) / 2);
        if (array[middle] <= target) {
            min = middle + 1;
        }
        else {
            max = middle - 1;
        }
    }

    return min;
}
