'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const N = tmp[0][0];
  const A = tmp[1].sort((a,b)=>a-b);
  const B = tmp[2];
  const C = tmp[3].sort((a,b)=>a-b);
  let count = 0;
  for ( let i = 0; i < N; i++ ) {
    let a = -1, a_ = N;
    while ( a_ - a > 1 ) {
      const m = parseInt( a + ( a_ - a ) / 2, 10);
      if ( A[m] >= B[i] ) a_ = m;
      else a = m;
    }
    let c_ = -1, c = N;
    while ( c - c_ > 1 ) {
      const m = parseInt( c_ + ( c - c_ ) / 2, 10);
      if ( C[m] > B[i] ) c = m;
      else c_ = m;
    }
    count += (a+1)*(N-c);
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
