#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int N;
int a[3][100010];
int main() {
	scanf("%d",&N);
	for (int j = 0; j < 3;j++) {
		for (int i = 0; i < N; i++) {
			scanf("%d", &a[j][i]);
		}
		sort(a[j], &a[j][N]);
	}
	LL ans = 0;
	for (int i = 0; i < N;i++) {
		ans += (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]));
	}
	printf("%lld\n",ans);
	return 0;
}