#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll N_MAX{ 100001 };
ll N, A[N_MAX], B[N_MAX], C[N_MAX], ans;
int main() {
    cin.sync_with_stdio(0), cin.tie(0);
    cin >> N;
    for(int i{}; i < N; ++i) cin >> A[i];
    for(int i{}; i < N; ++i) cin >> B[i];
    for(int i{}; i < N; ++i) cin >> C[i];
    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);
    for(int i{}; i < N; ++i)
        ans += distance(A, lower_bound(A, A + N, B[i]))
            * (N - distance(C, lower_bound(C, C + N, B[i] + 1)));
    cout << ans << endl;
}
