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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n;
	cin >> n;
	vector<i64> va(n);
	REP(i, SIZE(va)) { cin >> va[i]; }
	vector<i64> vb(n);
	REP(i, SIZE(vb)) { cin >> vb[i]; }
	vector<i64> vc(n);
	REP(i, SIZE(vc)) { cin >> vc[i]; }

	ALL(sort, va);
	ALL(sort, vb);
	ALL(sort, vc);

	//map<i64, i64> a;
	//REP(i, n) { i64 v; cin >> v; a[v]++; }
	//map<i64, i64> b;
	//REP(i, n) { i64 v; cin >> v; b[v]++; }
	//map<i64, i64> c;
	//REP(i, n) { i64 v; cin >> v; c[v]++; }

	//vector<i64> va;
	//REPIT(a) { va.push_back((*it).first); }
	//vector<i64> vb;
	//REPIT(b) { vb.push_back((*it).first); }
	//vector<i64> vc;
	//REPIT(c) { vc.push_back((*it).first); }

	i64 ans = 0;
	i64 pre_num = -1, pre_sum = -1;
	REP(i, SIZE(vb))
	{
		i64 sum = 0;
		if (pre_num == vb[i])
		{
			sum = pre_sum;
		}
		else
		{
			i64 lsum = 0;
			if (va[n - 1] < vb[i])
				lsum = n;
			else if (va[0] >= vb[i])
				lsum = 0;
			else
			{
				auto lit = lower_bound(all(va), vb[i]);
				if (lit == va.end())
					continue;
				lsum = lit - va.begin();
			}

			i64 rsum = 0;
			if (vc[0] > vb[i])
				rsum = n;
			else if (vc[n - 1] <= vb[i])
				rsum = 0;
			else
			{
				auto uit = upper_bound(all(vc), vb[i]);
				if (uit == vc.end())
					continue;
				rsum = vc.end() - uit;
			}

			sum = lsum * rsum;
			pre_num = vb[i];
			pre_sum = sum;
		}
		ans += sum;
	}


	//i64 i_b = 0, i_c = 0, ans = 0;
	//REP(i, SIZE(va))
	//{
	//	FOR(j, i_b, SIZE(vb))
	//	{
	//		if (va[i] < vb[j])
	//		{
	//			FOR(k, i_c, SIZE(vc))
	//			{
	//				if (vb[j] < vc[k])
	//				{
	//					ans += a[va[i]] * b[vb[j]] * c[vc[k]];
	//				}
	//			}
	//		}
	//	}
	//}


	//priority_queue<i64, vector<i64>, greater<i64>> qa;
	//REPIT(a) { qa.push((*it).first); }
	//priority_queue<i64, vector<i64>, greater<i64>> qb;
	//REPIT(b) { qb.push((*it).first); }
	//priority_queue<i64, vector<i64>, greater<i64>> qc;
	//REPIT(c) { qc.push((*it).first); }

	//i64 ans = 0;
	//while (!qa.empty())
	//{
	//	i64 num_a = qa.top();
	//	priority_queue<i64, vector<i64>, greater<i64>> cur_qb(qb);
	//	while (!cur_qb.empty())
	//	{
	//		if (cur_qb.top() > num_a)
	//		{
	//			i64 num_b = cur_qb.top();
	//			priority_queue<i64, vector<i64>, greater<i64>> cur_qc(qc);
	//			while (!cur_qc.empty())
	//			{
	//				if (cur_qc.top() > num_b)
	//				{
	//					ans += a[num_a] * b[num_b] * c[cur_qc.top()];
	//				}
	//				cur_qc.pop();
	//			}
	//		}
	//		cur_qb.pop();
	//	}
	//	qa.pop();
	//}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 2560