#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    int64_t ans = 0;
    rep(i,n) {
        int64_t d = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        int64_t u = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += d * u;
    }
    cout << ans << endl;
}