//#include <bits/stdc++.h>
//#include<ext/pb_ds/priority_queue.hpp>
//using namespace __gnu_pbds
//#pragma warning(disable:4786)//使命名长度不受限制
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <vector>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define Open() freopen("test.in","r",stdin)
#define Close() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Clear(x,y) memset(x, y, sizeof x)
#define mmax(x,y,z) max(x, max(y,z));
#define pii pair<int,int>
#define piii pair<int, pair<int,int> >
#define pti pair<type, int>
#define ptii pair<type, pair<int,int> >
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y0 yzz
#define y1 yzzz
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define root 1, n, 1
#define lson l, mid, rt<<1
#define rson mid+1, r, rt<<1|1
#define debug()  cout << "your code can go to there!\n"
ll qmod(ll a, ll n, ll mod){ll ans=1; while(n){if(n&1ll){ans = ans * a % mod;} n >>= 1; a = a * a % mod;} return ans;}
template<class T> inline T lowbit(T x){return x & -x;}
template<class T> inline T sqr(T x){return (x) * (x);}
template<class T> inline T my_pow(T a, T n){T ans=1; while(n){if(n&1ll){ans = ans * a;} n >>= 1; a = a * a;} return ans;}
/* fastIO  */
template<class T> inline bool scan(T & ret){
        char c;
        int sgn;
        if (c = getchar(), c == EOF) return 0; //EOF
        while (c != '-' && (c < '0' || c > '9') ) c = getchar();
        sgn = (c == '-') ? -1 : 1;
        ret = (c == '-') ? 0 : (c - '0');
        while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
        ret *= sgn;
        return 1;
}
/* file fastIO  more fast than the above one*/
struct FastIO{ //int a = io.xint();
    static const int S = 100 << 1;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar(){
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len){
            pos = 0;
            len = (int)fread(buf, 1, S, stdin);
        }
        if (pos == len){
            return -1;
        }
        return buf[pos++];
    }
    inline int xint(){
        int s = 1, c = xchar(), x = 0;
        while (c <= 32){
            c = xchar();
        }
        if (c == '-'){
            s = -1;
            c = xchar();
        }
        for (; '0' <= c && c <= '9'; c = xchar()){
            x = x * 10 + c - '0';
        }
        return x * s;
    }
    ~FastIO(){
        if (wpos){
            fwrite(wbuf, 1, wpos, stdout);
            wpos = 0;
        }
    }
} io;

const ll mod = 1e9+7;
const double pi = 3.14159265358979323846264338327950288L;
const double eps = 1e-3;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5+10;
const int maxm = 100010;

//-------------------BlockChanZJ-----------------------//

int a[maxn], b[maxn], c[maxn];
ll suf[maxn], sum[maxn];
int n;

int Find(int x, int a[]){
        int l = 1, r = n, mid, ans = -1;
        while(l <= r){
                mid = l+r >> 1;
                if(a[mid] > x) ans = mid, r = mid-1;
                else l = mid + 1;
        }
        return ans;
}

int main(){
        //Open();
        n = io.xint();
        for(int i = 1; i <= n; ++i) a[i] = io.xint();
        for(int i = 1; i <= n; ++i) b[i] = io.xint();
        for(int i = 1; i <= n; ++i) c[i] = io.xint();
        sort(a+1,a+1+n);sort(b+1,b+1+n);sort(c+1,c+1+n);
        for(int i = 1; i <= n; ++i){
                int x = Find(b[i], c);
                if(x == -1) suf[i] = 0;
                else suf[i] = n - x + 1;
        }
        for(int i = n; i >= 1; --i){
                sum[i] = sum[i+1] + suf[i];
        }
        ll fuck = 0;
        for(int i = 1; i <= n; ++i){
                int x = Find(a[i], b);
                if(x == -1) continue;
                else fuck += sum[x];
        }
        printf("%lld\n",fuck);
        return 0;
}


Measured memory_bytes: 2944