#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)



using namespace std;
int main(){
 int n;
  cin >> n;
  int64_t A[n];
  int64_t B[n];
  int64_t C[n];
  repz( i , n) cin >> A[i];
  repz( i , n) cin >> B[i];
  repz( i , n) cin >> C[i];
  sort(A, A + n);
  sort(C, C + n);
    int64_t ans = 0; int64_t a = 0; int64_t c = 0;
    for ( int64_t i : B){
        a = lower_bound(A, A + n, i ) - A ;
        c = upper_bound(C, C + n , i) - C;
        ans += a * (n - c);
    }
    cout << ans << endl;


    
}

// Problem : C - Snuke Festival
// Contest : AtCoder - AtCoder Beginner Contest 077
// URL : https://atcoder.jp/contests/abc077/tasks/arc084_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int n;cin>>n;
	vi a(n),b(n),c(n);cin>>a>>b>>c;
	sort(all(a));
	sort(all(b));
	sort(all(c));
	int ans=0;
	int suff[n];
	for(int i=n-1;i>=0;i--)
	{
		int ind=upper_bound(all(c),b[i])-c.begin();
		if(i==n-1)
		{
			suff[n-1]=n-ind;
		}
		else
		{
			suff[i]=n-ind;
			suff[i]+=suff[i+1];
		}
	}
	for(int i=0;i<n;i++)
	{
		int ind=upper_bound(all(b),a[i])-b.begin();	
		if(ind<n)	
		ans+=suff[ind];
	}
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}
