using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C077
    {

        //ヒストグラムから累積和を作成
        //dicCountは昇順ソートされている必要.
        static Dictionary<T, long> SumTable<T>(Dictionary<T, long> dicCount)
        {
            Dictionary<T, long> dic = new Dictionary<T, long>();
            long counter = 0;
            foreach (var v in dicCount)
            {
                counter += v.Value;
                dic.Add(v.Key, counter);
            }
            return dic;
        }

        //ソート済みListの中でvalue以下の最大の要素を取得O(log n)
        //Listの最小値よりも小さい場合はdefを返す
        static T MaxEqualOrLessThan<T>(List<T> list, T value, T def)
            where T : IComparable
        {
            if (value.CompareTo(list[0]) < 0) return def;

            int s = 0;
            int t = list.Count();
            while (s + 1 < t)
            {
                int k = s + (t - s) / 2;
                int c = value.CompareTo(list[k]);
                if (c == 0)
                {
                    return value;
                }
                else if (c > 0)
                {
                    s = k;
                }
                else
                {
                    t = k;
                }
            }

            return list[s];
        }


        static void Main(string[] args)
        {
            //string path = @"C:\temp\01.txt";
            //System.IO.StreamReader sr = new System.IO.StreamReader(path);
            //Console.SetIn(sr);


            int N = int.Parse(Console.ReadLine());
            List<int> A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            List<int> B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            List<int> C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            A.Sort(); B.Sort(); C.Sort();

            var adic = A.ToLookup(x => x).ToDictionary(x => x.Key, x => (long)x.Count());
            var asum = SumTable(adic);
            var akeys = asum.Keys.ToList();

            var bdic = B.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());

            Dictionary<int, long> bcount = new Dictionary<int, long>();
            foreach (var pair in bdic)
            {
                int k = pair.Key;
                int key = MaxEqualOrLessThan(akeys, k - 1, -1);
                if (key < 0) bcount.Add(k, 0);
                else
                {
                    long cB = (long)pair.Value * asum[key];
                    bcount.Add(k, cB);
                }
            }
            var bsum = SumTable(bcount);
            var bkeys = bsum.Keys.ToList();

            var cdic = C.ToLookup(x => x).ToDictionary(x => x.Key, x => x.Count());

            Dictionary<int, long> ccount = new Dictionary<int, long>();
            foreach (var pair in cdic)
            {
                int k = pair.Key;
                int key = MaxEqualOrLessThan(bkeys, k - 1, -1);
                if (key < 0) ccount.Add(k, 0);
                else
                {
                    long cC = (long)pair.Value * bsum[key];
                    ccount.Add(k, cC);
                }
            }

            long count = ccount.Sum(x => x.Value);
            Console.WriteLine(count);


        }

    }
}


Measured memory_bytes: 74512