(function() {
    'use strict';

    var lines = [];
    require('readline').createInterface({
      input: process.stdin,
      output: process.stdout
    }).on('line', function(line) {
      lines.push(line);
    });
    process.stdin.on('end', function() {
      //lines.forEach(function(line) {
        //var tokens = line.split(' ').map(Number);
        //    console.log(tokens[0] + ' ' + tokens[1]);
      //}
      //)
      ;

    // ToDo start
      var N = parseInt(lines[0])
      var A =lines[1].split(" ")
      var B =lines[2].split(" ")
      var C =lines[3].split(" ")
      var ans = 0

        //sort
        for(var ai=0;ai<N;ai++){
            A[ai] = ("000000000" + (""+A[ai]) ).slice(-9)
        }
        A = A.sort()
        for(var bi=0;bi<N;bi++){
            B[bi] = ("000000000" + (""+B[bi]) ).slice(-9)
        }
        B = B.sort()
        for(var bi=0;bi<N;bi++){
//            console.log(B[bi])
        }
        
        for(var ci=0;ci<N;ci++){
            C[ci] = ("000000000" + (""+C[ci]) ).slice(-9)
        }
        C = C.sort()
        

      for (var ai=0;ai<N;ai++){
          bloop:for (var bi=N-1;bi>=0;bi--){
              if( A[ai] < B[bi] ) {
                  //console.log("A:"+A[ai] + " B:"+B[bi])
                cloop:for (var ci=0;ci<N;ci++){
                    if( B[bi] < C[ci] ){
//                        console.log("ai:"+A[ai] + " bi:"+B[bi] + " ci:"+C[ci])
                        ans = ans + N-ci
//                        console.log("ans:"+ans)
                        break cloop;
                    }
                 }
               }else{
                   break bloop;
               }
          }
       }

    console.log(ans)
      
//      console.log( Math.pow(parseInt(lines[0]),2) - parseInt(lines[1])  )
    // ToDo end

    });


})();

