# include <iostream>
# include <algorithm>

using namespace std;

int const MAX = 1e5+2;

int N;
long long A[MAX], B[MAX], C[MAX];
long long ans = 0;

int main(){
    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(C, C + N);

    for (int i = 0; i < N; i++){
            ans 
            += (lower_bound(A, A+N, B[i]) - A)
            * (C + N - upper_bound(C, C+N, B[i]));
    }

    cout << ans;
}