'use strict'

function main(input){
  const lines = input.split('\n');
  const N  =parseInt(lines.shift());
  const A = lines.shift().split(' ').map(x => parseInt(x)).sort((a,b) => a-b);
  const B = lines.shift().split(' ').map(x => parseInt(x)).sort((a,b) => a-b);
  const C = lines.shift().split(' ').map(x => parseInt(x)).sort((a,b) => a-b);


//console.log(A);
//console.log(B);
//console.log(C);

  let result = 0;

  for(let b=0;b<N;b++){
    let current_b = B[b];

    let count_a = 0;
    for(let a=0;a<N;a++){
      if(A[a] >= current_b ){
        count_a = a;
        break;
      }
    }
    if(Math.max(...A)<current_b){count_a =N;}
    if(Math.min(...A)>=current_b){count_a =0;}

    let count_c = 0;
    for(let c=0;c<N;c++){
      if(current_b < C[c]){
        count_c = N-c;
        break;
      }
    }
    if(Math.min(...C)>current_b){count_c =N;}
    if(Math.max(...C)<=current_b){count_c =0;}

//console.log([count_a,count_c])
    result += count_a*count_c
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
