#include <cstdio>
#include <algorithm>
using namespace std;
long long f[100005],ans,a[100005],b[100005],c[100005],n;

int main(){
	scanf("%lld",&n);
	for (int i=1; i<=n; i++) scanf("%lld",&a[i]); sort(a+1,a+n+1);
	for (int i=1; i<=n; i++) scanf("%lld",&b[i]); sort(b+1,b+n+1);
	for (int i=1; i<=n; i++) scanf("%lld",&c[i]); sort(c+1,c+n+1);
	for (int i=n,j=n; i; i--){		//中间层选 b[i] 
		for (; j && c[j]>b[i]; j--);	//底层最小可以选 c[j]
		f[i]=f[i+1]+n-j;	//方案的前缀 
	}
	for (int i=n,j=n; i; i--){
		for (; j && b[j]>a[i]; j--);
		ans+=f[j+1];
	}
	printf("%lld",ans);
}