#import <stdio.h>
#import <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

// values の中で初めて searchValue を超える index を探す（ない場合は -1 を返す）
int binary_search(int searchValue, int *values, int minIndex, int maxIndex) {
    int midIndex = (minIndex + maxIndex)/2;
    int midValue = values[midIndex];
    if (minIndex == midIndex) {
        if (searchValue < midValue) {
            return midIndex;
        }
        int maxValue = values[maxIndex];
        if (searchValue < maxValue) {
            return maxIndex;
        }
        return -1;
    }
    if (midValue <= searchValue) {
        return binary_search(searchValue, values, midIndex, maxIndex);
    } else {
        return binary_search(searchValue, values, minIndex, midIndex);
    }
}

int main(){
    int N;
    scanf("%d", &N);
    int A[100002] = {0};
    int B[100002] = {0};
    int C[100002] = {0};
    for(int i=0;i<N;i++){
        int a;
        scanf("%d", &a);
        A[i] = a;
    }
    for(int i=0;i<N;i++){
        int b;
        scanf("%d", &b);
        B[i] = b;
    }
    for(int i=0;i<N;i++){
        int c;
        scanf("%d", &c);
        C[i] = c;
    }
    qsort(A, N, sizeof(int), compare_int);
    qsort(B, N, sizeof(int), compare_int);
    qsort(C, N, sizeof(int), compare_int);
    long count = 0;
    for(int i=0;i<N;i++){
        int a = A[i];
        int j = binary_search(a,B,0,N-1);
        if (j<0) break;
        for(int J=j;J<N;J++){
            int b = B[J];
            int k = binary_search(b, C, 0, N-1);
            if (k<0) break;
            count += N-k;
        }
    }
    printf("%ld",count);
}
