#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp make_pair
#define pb push_back
#define mes(a,b) memset(a,b,sizeof(a))
#define mes0(a) memset(a,0,sizeof(a))
#define lson l,mid,pos<<1
#define rson mid+1,r,pos<<1|1
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define fi first
#define se second
#define sss(a) a::iterator
#define all(a) a.begin(),a.end()
#define READ_INTEGER \
{ \
    x=0;\
    int f=1;char ch=_getchar();\
    while((ch<'0'||ch>'9')&&~ch){if(ch=='-')f=-1;ch=_getchar();}\
    if (ch==-1)return -1;\
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=_getchar();}\
    x*=f;\
    return 1;\
}
#define READ_REAL \
{\
        char in;double Dec=0.1;\
        bool IsN=false,IsD=false;\
        in=_getchar();\
        if(in==EOF) return -1;\
        while(in!='-'&&in!='.'&&(in<'0'||in>'9'))\
                in=_getchar();\
        if(in=='-'){IsN=true;x=0;}\
        else if(in=='.'){IsD=true;x=0;}\
        else x=in-'0';\
        if(!IsD){\
                while(in=_getchar(),in>='0'&&in<='9'){\
                        x*=10;x+=in-'0';}\
        }\
        if(in!='.'){\
                if(IsN) x=-x;\
                return 1;\
        }else{\
                while(in=_getchar(),in>='0'&&in<='9'){\
                        x+=Dec*(in-'0');Dec*=0.1;\
                }\
        }\
        if(IsN) x=-x;\
        return 1;\
}
#define READ_STRING \
{\
    char *tmp=x;\
    char in=_getchar();\
    while(in<=' '&&in!=EOF)in=_getchar();\
    if (in==-1)return -1;\
    while (in>' ')*(tmp++)=in,in=_getchar();\
    *tmp='\0';\
    return 1;\
}
using namespace std;
typedef double DB;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<long long ,int> pli;
typedef pair<int,long long > pil;
typedef pair<string,int> psi;
typedef pair<long long ,long long > pll;

const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double pi = acos(-1.0);
const int maxn = 100000+10;
const int mod = 1e9+7;

inline char _getchar()
{
    static const int BUFSIZE = 100001 ;
    static char  buf[BUFSIZE] ;
    static char  *psta=buf, *pend=buf ;
    if (psta >= pend){
        psta = buf;
        pend = buf + fread(buf,1,BUFSIZE,stdin);
        if (psta >= pend)
            return -1;
    }
    return *psta++;
}
inline int read(int &x) READ_INTEGER
inline int read(long long &x) READ_INTEGER
inline int read(double &x) READ_REAL
inline int read(float &x) READ_REAL
inline int read(char *x) READ_STRING
int a[maxn];
int b[maxn];
int c[maxn];
long long d[maxn];
int main()
{
    long long ans=0;
    int n;
    read(n);
    for (int i=0;i<n;i++)read(a[i]);
    for (int i=0;i<n;i++)read(b[i]);
    for (int i=0;i<n;i++)read(c[i]);
    sort(a,a+n),sort(b,b+n),sort(c,c+n);
    long long pre=0;
    int j=0;
    for (int i=0;i<n;i++){
        while (j<n&&a[j]<b[i])j++;
        d[i]=j;
    }
    j=0;
    for (int i=0;i<n;i++){
        while (j<n&&b[j]<c[i])pre+=d[j],j++;
        ans+=pre;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304