#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL A[100000];
LL B[100000];
LL C[100000];
LL sum[100000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) cin >> C[i];
	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);
	for (int i = N - 1; i >= 0; i--) {
		sum[i] = (C + N) - upper_bound(C, C + N, B[i]);
		if (i + 1 < N) sum[i] += sum[i + 1];
	}
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		int pos = upper_bound(B, B + N, A[i]) - B;
		if (pos < N) ans += sum[pos];
	}
	cout << ans << endl;
}