sort+二分,没啥技巧的做法
//O(nlog(n)log(n))
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
typedef long long LL;
int a[N], b[N], c[N];
int main()
{
long long n, ans = 0;
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 = 0;i < n;i++) {
int pos1 = lower_bound(a, a + n, b[i]) - a;
if(pos1 == 0) continue;
int pos2 = upper_bound(c, c + n, b[i]) - c;
if(pos2 == n) continue;
ans += 1ll * pos1 * (n - pos2);
}
cout << ans << endl;
return 0;
}