#include <bits/stdc++.h>
using namespace std;

vector <int> a, b, c;
long long x, y, n, ans;

int main () {
	cin>>n;
	
	
	for(int i=0; i<n; i++){
		cin>>x;
		a.push_back(x);
	}
	for(int i=0; i<n; i++){
		cin>>x;
		b.push_back(x);
	}
	for(int i=0; i<n; i++){
		cin>>x;
		c.push_back(x);
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	
	for(int i=0; i<n; i++){
		x=(lower_bound(a.begin(), a.end(), b[i])-a.begin());
		y=(c.end()-upper_bound(c.begin(), c.end(), b[i]));
		
		ans+=x*y;
	}
	
	cout<<ans<<endl;
}
