#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100010;
int n,a[maxn],b[maxn],c[maxn];
long long d[maxn],ans;
int main() {
	scanf("%d",&n); 
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	for(int i=1;i<=n;i++)
		scanf("%d",b+i);
	for(int i=1;i<=n;i++)
		scanf("%d",c+i);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	for(int i=n;i>=1;i--)
		d[i]=d[i+1]+(n-(int)(upper_bound(c+1,c+n+1,b[i])-c)+1);
	for(int i=1;i<=n;i++)
		ans+=d[upper_bound(b+1,b+n+1,a[i])-b];
	printf("%lld\n",ans);
	return 0;
}