#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

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];
    ssort(a); ssort(b); ssort(c);
    vector<ll> upc(n), acu_upc(n);
    rep (i, n) {
        auto it = upper_bound(c.begin(), c.end(), b[i]);
        int cnt = c.end() - it;
        if (cnt < 0) cnt = 0;
        upc[i] = cnt;
    }
    acu_upc[n - 1] = upc[n-1];
    rrepSE (i, n - 2, -1) {
        acu_upc[i] = acu_upc[i+1] + upc[i];
    }
    ll ans = 0;
    rep(i,n) {
        auto it = upper_bound(b.begin(), b.end(), a[i]);
        int j = it - b.begin();
        if (j<=n-1) {
            ans += acu_upc[j];
        }
    }
    cout << ans << "\n";
    return 0;
}

#include<iostream>
using namespace std;
const int maxn = 200001;
const int INF = 0x7fffffff;

int L[maxn], R[maxn];
long long merge(int A[], int n, int left, int mid, int right)
{
    int i, j, k;
    long long cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;

    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = INF;

    i = j = 0;
    for(int k = left; k < right; k++)
    {
        if(L[i] <= R[j])
            A[k] = L[i++];
        else
        {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

long long mergeSort(int A[], int n, int left, int right)
{
    int mid;
    long long v1, v2, v3;
    if(left + 1 < right)
    {
        mid = (left + right) / 2;
        v1 = mergeSort(A, n, left, mid);
        v2 = mergeSort(A, n, mid, right);
        v3 = merge(A, n, left, mid, right);
        return v1 + v2 + v3;
    }
    else
        return 0;
}

int main()
{
    int A[maxn], n;

    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> A[i];

    long long ans = mergeSort(A, n, 0, n);
    cout << ans << endl;
    return 0;
}
