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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (auto &a : A) cin >> a;
    for (auto &b : B) cin >> b;
    for (auto &c : C) cin >> c;
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());
    long long ans = 0;
    for (auto b : B)
    {
        ans += distance(A.begin(), lower_bound(A.begin(), A.end(), b)) * distance(upper_bound(C.begin(), C.end(), b), C.end());
    }
    cout << ans << endl;
    return 0;
}