#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
    int n;cin>>n;
    int a[3][n];
    REP(i,3)REP(j,n)cin>>a[i][j];
    REP(i,3)sort(a[i],a[i]+n);
    long int s=0;
    REP(i,n)s+=(lower_bound(a[0],a[0]+n,a[1][i])-a[0])*(a[2]+n-upper_bound(a[2],a[2]+n,a[1][i]));
    cout<<s<<endl;
}