#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
int A[3][100001];
LL dp[3][100001] = {};

int main() {
    scanf("%d", &N);
    rep(j, 3) { rep(i, N) scanf("%d", &A[j][i]); A[j][N] = 1000000001; }
    rep(j, 3) sort(A[j], A[j] + N);
    rep(i, N + 1) dp[0][i] = i;
    rep(j, 2) {
        int p = 0;
        rep(i, N) {
            while (A[j][p] < A[j + 1][i]) p++;
            dp[j + 1][i + 1] += dp[j + 1][i] + dp[j][p];
        }
    }
    printf("%lld\n", dp[2][N]);
    return 0;
}
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  vector<ll> na(n, 0);
  vector<ll> nb(n, 0);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  for(int i = 0; i < n; ++i) cin >> c[i];

  sort(ALL(b));
  sort(ALL(c));

  for(int i = 0; i < n; ++i)
  {
    auto itc = upper_bound(ALL(c), b[i]);
    nb[i] = distance(itc, c.end());
  }
  for(int i = n - 2; i >= 0; --i)
  {
    nb[i] += nb[i + 1];
  }
  for(int i = 0; i < n; ++i)
  {
    auto itb = upper_bound(ALL(b), a[i]);
    na[i] = nb[distance(b.begin(), itb)];
  }
  cout << accumulate(ALL(na), 0LL);
}

int main()
{
  fastio;
  solve();

  return 0;
}