#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define inf INT_MAX
#define sz(name) name.size()
#define len(name) name.length()
#define ig cin.ignore()
#define sc1(name) scanf("%d",&name)
#define sc2(name1,name2) scanf("%d%d",&name1,&name2)
#define sc3(name1,name2,name3) scanf("%d%d%d",&name1,&name2,&name3)
#define scl1(name) scanf("%lld",&name)
#define scl2(name1,name2) scanf("%lld%lld",&name1,&name2)
#define scl3(name1,name2,name3) scanf("%lld%lld%lld",&name1,&name2,&name3)
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define Forr(name,start,finish) for(int name=start;name>=finish;name--)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int row[]={0,1,0,-1};
int col[]={1,0,-1,0};

const ll N=1e5+10;
const ll M=1e18+7;
const ll H=1e9+9;
const ll base=131;

ll logx(ll a,ll bs){return log(a)/log(bs);}
ll Max(ll a,ll b){if(a>b)return a;return b;}
ll Min(ll a,ll b){if(a>b)return b;return a;}
ll big_mul(ll a,ll b,ll m){ll x=0,y=a%m;while(b>0){if(b&1)x=(x+y)%m;y=(2*y)%m;b>>=1;}return x%m;}
ll big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=(x*y)%m;y=(y*y)%m;b>>=1;}return x%m;}
ll Big_mod(ll a,ll b,ll m){ll x=1,y=a%m;while(b>0){if(b&1)x=big_mul(x,y,m);y=big_mul(y,y,m);b>>=1;}return x%m;}
ll mod_inverse(ll a,ll m){return big_mod(a,m-2,m);}  //a^-1 mod m = a^(m-2) mod m
ll GCD(ll a,ll b){if(!a)return b;return GCD(b%a,a);}


vector<int> vec1;
vector<int> vec2;
vector<int> vec3;
vector<ll> ans(N);

ll bs1(int l,int r,int value)
{
    while(r-l>3)
    {
        int mid=(l+r)/2;

        if(vec3[mid]<=value)
            l=mid;

        else
            r=mid;
    }

    For(i,l,r+1)
    {
        if(vec3[i]>value)
            return sz(vec3)-i;
    }

    return 0;
}

ll bs2(int l,int r,int value)
{
    while(r-l>3)
    {
        int mid=(l+r)/2;

        if(vec1[mid]>=value)
            r=mid;

        else
            l=mid;
    }

    Forr(i,r,l)
    {
        if(vec1[i]<value)
            return i+1;
    }

    return 0;
}

int main()
{

    fast_in_out;

    int n;
    cin>>n;

    For(i,0,n)
    {
        int a;
        cin>>a;

        vec1.pb(a);
    }

    Sort(vec1);

    For(i,0,n)
    {
        int a;
        cin>>a;

        vec2.pb(a);
    }

    For(i,0,n)
    {
        int a;
        cin>>a;

        vec3.pb(a);
    }

    Sort(vec3);

    For(i,0,n)
    ans[i]=bs1(0,n-1,vec2[i])*bs2(0,n-1,vec2[i]);

    ll cnt=0;

    For(i,0,n)
    cnt+=ans[i];

    cout<<cnt<<endl;

    return 0;
}

