#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O30")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << (x) << "\n")
using ll = long long; using ld = long double; using namespace std;

ll N, cnt;
void all( ) {
	vector<vector<ll>> A;
	iss >> N; A.resize(3, vector<ll>(N));
	for (auto &abc : A) {
		for (auto &a : abc)  iss >> a;
	}		
	sort(begin(A[0]), end(A[0]));
	sort(begin(A[2]), end(A[2]));
	for (auto &b : A[1]) {
		cnt += (end(A[2]) - upper_bound(begin(A[2]), end(A[2]), b))
			* (lower_bound(begin(A[0]), end(A[0]), b) - begin(A[0]));
	}
	p(cnt);
}
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	all( );
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1e9+7;
using namespace std;
using ll = long long;

int main() {
	ll n, ans = 0;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	rep(i,n) cin >> b[i];
	sort(b.begin(), b.end());
	rep(i,n) cin >> c[i];
	sort(c.begin(), c.end());

	for (int i = 0; i < n; i++) {
		ll L = -1 , R = n;

		while (abs(L - R) > 1) {
			int mid = (L + R) / 2;
			if (a[mid] < b[i]) L = mid;
			else R = mid;
		}
		ll down = L;

		L = -1; R = n;

		while (abs(L - R) > 1) {
			int mid = (L + R) / 2;
			if (c[mid] > b[i]) R = mid;
			else L = mid;
		}
		ll up = R;
		ans += (down + 1) * (n - up);
	}
	cout << ans << endl;
	return 0;
}