#include<bits/stdc++.h>
using namespace std;
#define LL long long
int a[100005],b[100005],c[100005];
LL bc[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;++i){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<n;++i){
		scanf("%d",&c[i]);
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);
	LL sum=0;
	int k=0;
	for(int i=0;i<n;++i){
		while(k<n&&c[k]<=b[i])++k;
		bc[i]=n-k;
	}
	for(int i=n-1;i>=0;--i){
		bc[i]=bc[i+1]+bc[i];
	}
	k=0;
	for(int i=0;i<n;++i){
		while(k<n&&b[k]<=a[i])++k;
		sum+=bc[k];
	}
	printf("%lld\n",sum);
} 