/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/04 11:24:55 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	int	n;
	cin >> n;

	int ans;
	ans = 0;
	VVI	V(3, VI(n));
	rep(i, 3)
	{
		rep(j, n)
			cin >> V.at(i).at(j);
		// sort(V.at(i).begin(), V.at(i).end());
	}
	sort(V.at(0).begin(), V.at(0).end());
	sort(V.at(2).begin(), V.at(2).end());
	// VI	A(n);
	rep(i, n)
	{

		int a;
		int b;
		int	x;
		x = V.at(1).at(i);
		a = lower_bound(V.at(0).begin(), V.at(0).end(), x) - V.at(0).begin();
		b = V.at(2).end() - upper_bound(V.at(2).begin(), V.at(2).end(), x);
		ans += a * b;
	}
	// int	sum;
	// sum = 0;
	// rrep(i, n - 1)
	// {
	// 	int x;

	// 	x = V.at(2).end() - upper_bound(V.at(2).begin(), V.at(2).end(), V.at(1).at(i));
	// 	sum += x;
	// 	A.at(i) = sum;
	// }
	// rep(i, n)
	// {
	// 	int first_upper;

	// 	first_upper  = upper_bound(V.at(1).begin(), V.at(1).end(), V.at(0).at(i)) - V.at(1).begin();
	// 	if (first_upper != n)
	// 	ans += A.at(first_upper);
	// }
	// rep(i, n)
	// {
	// 	int	start  = upper_bound(V.at(1).begin(), V.at(1).end(), V.at(0).at(i)) - V.at(1).begin();
	// 	rep2(j, start, n)
	// 	{
	// 		int x = V.at(2).end() - upper_bound(V.at(2).begin(), V.at(2).end(), V.at(1).at(j));
	// 		ans += x;
	// 	}
	// }
	cout << ans << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3456