// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <iostream>

#include <stdio.h>

#include <map>

#include <math.h>



using namespace std;



int main()

{

    int x;

    while(~scanf("%d",&x))

    {

        int i,a[100100]= {0},b[100100]= {0},c[100100]= {0};

        long long d[100100]={0};

        for(i=1; i<=x; i++)

        {

            scanf("%d",&a[i]);

        }

        for(i=1; i<=x; i++)

        {

            scanf("%d",&b[i]);

        }

        for(i=1; i<=x; i++)

        {

            scanf("%d",&c[i]);

        }

        sort(a+1,a+1+x);

        sort(b+1,b+x+1);

        sort(c+1,c+x+1);

        for(i=1; i<=x; i++)

        {

            int l=1,r=x,mid;

            while(l<=r)

            {

                mid=l+(r-l)/2;

                if(a[mid]>=b[i])

                {

                    r=mid-1;

                }

                else if(a[mid]<b[i])

                {

                    l=mid+1;

                }

            }

            d[i]=d[i-1]+r;

        }

        long long sum=0;

        for(i=1; i<=x; i++)

        {

            int l=1,r=x,mid;

            while(l<=r)

            {

                mid=l+(r-l)/2;

                if(b[mid]>=c[i])

                {

                    r=mid-1;

                }

                else if(b[mid]<c[i])

                {

                    l=mid+1;

                }

            }

            sum=sum+d[r];

        }

        printf("%lld\n",sum);

    }

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 2.9754593925020445x):
#include <iostream>

#include <cmath>

#include <stdio.h>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <cstring>



using namespace std;



#define f first

#define s second

#define pb push_back

#define mp make_pair

#define ll long long

#define pii pair < int, int >

#define pll pair < long long, long long>

#define ull unsigned long long

#define vi vector < int >

#define vll vector < long long >

#define sz(a) (int)a.size()

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)

#define all(a) a.begin(), a.end()

#define sqr(x) ((x) * (x))

#define fname "searching"



const int inf = (int)1e9;

const ll INF = (ll)1e18;

const double eps = 1e-9;

const double pi = acos(-1.0);

const int mod = (int)1e9 + 7;



int n;

int a[100100];

int b[100100];

int c[100100];

ll d[100100];

ll sd[100100];

ll e[100100];

ll tot;



ll solve(){

    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(b, b + n);

    sort(c, c + n);

    

    for(int i = 0, j = 0; j < n; ++j){

        while(i < n && a[i] < b[j]) ++i;

        d[j] = i;

        sd[j] = d[j] + (i > 0 ? sd[j - 1] : 0);

    }

    for(int i = 0, j = 0; j < n; ++j){

        while(i < n && b[i] < c[j]) ++i;

        if(i > 0){

            tot += sd[i - 1];

            e[j] = sd[i - 1];

        }

    }

    

    // for(int i = 0; i < n; ++i) cout << a[i] << " ";

    // cout << "\n";

    // for(int i = 0; i < n; ++i) cout << b[i] << " ";

    // cout << "\n";

    // for(int i = 0; i < n; ++i) cout << c[i] << " ";

    // cout << "\n";



    // for(int i = 0; i < n; ++i) cout << d[i] << " ";

    // cout << "\n";

    // for(int i = 0; i < n; ++i) cout << sd[i] << " ";

    // cout << "\n";

    // for(int i = 0; i < n; ++i) cout << e[i] << " ";

    // cout << "\n";

    

    return tot;

}



int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0);



    cout << solve() << "\n";

    

    return 0;

}