// Original C++ solution (slower):
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cctype>

#include <algorithm>

#include <iostream>

#include <vector>

#include <set>

using namespace std;



typedef long long ll;

typedef double db;

typedef pair<int, int> pii;

typedef vector<int> vi;



namespace IO {

  static const int SZ = 1 << 20;

  static FILE *fin = stdin, *fout = stdout;

  static char ibuf[SZ], *is = ibuf, *it = ibuf;

  static char obuf[SZ], *os = obuf, *ot = obuf + SZ;

  

  inline char nextChar() {

    if (is == it) {

      it = (is = ibuf) + fread(ibuf, sizeof(char), SZ, fin);

      if (is == it)

        return EOF;

    }

    return *is++;

  }

  template <typename T>

  inline void readInt(T &x) {

    x = 0;

    T flag(1);

    char ch;

    for (ch = nextChar(); isspace(ch); ch = nextChar())

      ;

    if (ch == '-')

      ch = nextChar(), flag = -flag;

    for (; isdigit(ch); ch = nextChar())

      x = x * 10 + ch - '0';  

    x *= flag;

  }

  inline void readCh(char &now) {

    for (now = nextChar(); isspace(now); now = nextChar())

      ;  

  }

  

  inline void flushBuffer() {

    fwrite(obuf, sizeof(char), os - obuf, fout);

    os = obuf;

  }

  inline void printChar(char ch) {

    if (os == ot)

      flushBuffer();

    *os++ = ch;

  }

  template <typename T>

  inline void printInt(T x) {

    static int dig[20], cnt;

    if (os + 20 > ot)

      flushBuffer();

    if (x < 0)

      *os++ = '-', x = -x;

    cnt = 0;

    do {

      dig[++cnt] = x % 10;

      x /= 10;

    } while (x);

    for (int i = cnt; i > 0; --i)

      *os++ = dig[i] + '0';

  }

}



using namespace IO;



const int N = 1e5 + 5;



int n, a[N], b[N], c[N];

ll total;



int main() {

#ifdef LOCAL_DEBUG

  freopen("test.in", "r", stdin);

  freopen("test.out", "w", stdout);

#endif

  readInt(n);

	for (int i = 1; i <= n; ++i) readInt(a[i]);

	for (int i = 1; i <= n; ++i) readInt(b[i]);

	for (int i = 1; i <= n; ++i) readInt(c[i]);

	sort(a + 1, a + n + 1);

	sort(b + 1, b + n + 1);

	sort(c + 1, c + n + 1);

	total = 0;

	for (int i = 1; i <= n; ++i) {

		int len1 = lower_bound(a + 1, a + n + 1, b[i]) - a - 1;	

		int len3 = upper_bound(c + 1, c + n + 1, b[i]) - c;

		len3 = n - len3 + 1;

//		cerr << len1 << ' ' << len3 << endl;

		total = total + 1LL * len1 * len3;

	}

	printInt(total);

	printChar('\n');

  flushBuffer();

  return 0;

}

// Optimized solution to the same problem (faster):
#include <queue>

#include <cstdio>

#include <algorithm>

using namespace std;



static const int N = 1e5 + 10;

int n;

int a[N], b[N], c[N], cnt1[N], cnt2[N];



int main ()

{

	scanf ("%d", &n);

	for (int i = 1; i <= n; ++i)

		scanf ("%d", &a[i]);

	for (int i = 1; i <= n; ++i)

		scanf ("%d", &b[i]);

	for (int i = 1; i <= n; ++i)

		scanf ("%d", &c[i]);

	sort (a + 1, a + n + 1);

	sort (b + 1, b + n + 1);

	sort (c + 1, c + n + 1);

	int k = 1;

	for (int i = 1; i <= n; ++i)

	{

		for (; c[k] <= b[i] && k <= n ;)

			++k;

		cnt1[i] = n - k + 1;

	}

	k = 1;

	for (int i = 1; i <= n; ++i)

	{

		for (; a[k] < b[i] && k <= n ;)

			++k;

		cnt2[i] = k - 1;

	}

	long long ans = 0;

	for (int i = 1; i <= n; ++i)

		ans += (long long)cnt1[i] * cnt2[i];

	printf ("%lld", ans);

}

// Fastest known solution for this problem: