// 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: 3.053669383387962x):
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cmath>

#include <vector>

#include <cstring>

#include <algorithm>

#define Inf 0x3f3f3f3f

using namespace std;

typedef long long ll;

const int maxn=1e5+10;

int n,m,k;

int a[maxn];

int b[maxn];

int c[maxn];



ll erfen1(int l,int r,int key)

{

    int mid;

    while(l<=r)

    {

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

        if(a[mid]<key)

        {

            l=mid+1;

        }

        else

        {

            r=mid-1;

        }



    }

    return r;



}



ll erfen2(int l,int r,int key)

{

    int mid;

    while(l<=r)

    {

        mid=(l+r)/2;

        if(c[mid]>key)

        {

            r=mid-1;

        }

        else

        {

            l=mid+1;

        }



    }

    return l;

}



int main()

{

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

    {

        for(int i=0; i<n; i++)

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

        for(int i=0; i<n; i++)

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

        for(int i=0; i<n; i++)

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

        sort(a,a+n);

        sort(c,c+n);

        ll ans=0;

        for(int i=0; i<n; i++)

        {

            ll pos1=erfen1(0,n-1,b[i]);

            if(pos1<=n-1&&a[pos1]<b[i])

                pos1=pos1+1;

            else

                pos1=0;

            ll pos2=erfen2(0,n-1,b[i]);

           if(pos2>=0&&c[pos2]>b[i])

                pos2=n-pos2;

            else

                pos2=0;

           // printf("pos1=%lld pos2=%lld\n",pos1,pos2);

            ans+=pos1*pos2;

        }

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



    }

    return 0;

}