"use strict";
    
const binarySearch = (array, target, mode) => {
    let high = array.length - 1;
    let low  = 0;
    
    while(low < high) {
        let mid = Math.floor((low + high) / 2);
        
        if(target === array[mid]) {
            if(mode === "high") {
                let temp = mid;
                
                while(array[mid - 1] === array[mid]) {
                    temp--;
                }
                
                return temp;
            } else {
                let temp = mid;
                
                while(array[mid + 1] === array[mid]) {
                    temp++;
                }
                
                return temp + 1;
            }
        }
        
        if(target < array[mid]) {
            high = mid - 1;
        } else {
            low  = mid + 1;
        }
    }
    
    if(array[low] === target && mode === "low")
        return low + 1;
    if(array[low] < target)
        return low + 1;
    if(array[low] >= target)
        return low;
    return 0;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const top = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const mid = arg[2].split(" ").map(n=>parseInt(n));
    const low = arg[3].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    let cnt = 0;
    
    for(let i in mid) {
        let topNum = binarySearch(top, mid[i], "high");
        let lowNum = low.length - binarySearch(low, mid[i], "low");

        cnt += topNum * lowNum;
    }
    
    console.log(cnt);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
