#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long> a(n), b(n), c(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.begin(), a.end());
	sort(c.begin(), c.end());
	long long ans = 0;
	for(int i = 0; i < n; i++){
		long long cnt_a = 0, cnt_c = 0;
		cnt_a = distance(a.begin(), lower_bound(a.begin(), a.end(), b[i]));
		cnt_c = distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
		ans += cnt_a * cnt_c;
	}
	cout << ans << endl;
	return 0;
}