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

int N;
#define MAXN 100000
int A[MAXN], B[MAXN], C[MAXN];
long long n[MAXN], s[MAXN + 1];

int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) scanf("%d", &A[i]);
  for(int i = 0; i < N; ++i) scanf("%d", &B[i]);
  for(int i = 0; i < N; ++i) scanf("%d", &C[i]);
  sort(A, A + N); sort(B, B + N); sort(C, C + N);
  for(int i = 0; i < N; ++i) {
    n[i] = lower_bound(A, A + N, B[i]) - A;
    s[i + 1] = s[i] + n[i];
  }
  long long res = 0;
  for(int i = 0; i < N; ++i) {
    res += s[lower_bound(B, B + N, C[i]) - B];
  }
  printf("%lld\n", res);
  return 0;
}
