#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void MAIN() {
  int n;
  cin >> n;
  vector<vector<int>> a(3, vector<int>(n));
  vector<vector<int>> d(3, vector<int>(n));
  for (auto &i : a) {
    for (auto &j : i) cin >> j;
    sort(all(i));
  }
  for (int i = n - 1; i >= 0; i--) {
    d[2][i] = 1;
    if (i != n - 1) d[2][i] += d[2][i + 1];
  }
  for (int i = 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      int p = upper_bound(all(a[i + 1]), a[i][j]) - a[i + 1].begin();
      if (p != n) d[i][j] = d[i + 1][p];
      if (j != n - 1) d[i][j] += d[i][j + 1];
    }
  }
  cout << d[0][0] << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  vin a(n),b(n),c(n);
  rep(i,0,n)cin>>a[i];rep(i,0,n)cin>>b[i];rep(i,0,n)cin>>c[i];
  sort(all(a));sort(all(b));sort(all(c));reverse(all(c));
  ll ans=0;
  rep(i,0,n){
    int m=b[i];
    //二分探索
    ll acnt=0;
    int ok=-1,ng=n;
    while(ng-ok>1){
      int mid=ok+(ng-ok)/2;
      if(a[mid]<m)ok=mid;
      else ng=mid;
    }
    acnt=ok+1;
    ll ccnt=0;
    ok=-1,ng=n;
  //  cout<<m<<endl;
    while(ng-ok>1){
     // if(m==2)cout<<ok<<" "<<ng<<endl;
      int mid=ok+(ng-ok)/2;
      if(c[mid]>m)ok=mid;
      else ng=mid;
      
    }
    ccnt=ok+1;
   // cout<<acnt<<" "<<ccnt<<endl;
    ans+=acnt*ccnt;
  }
  cout<<ans<<endl;
}