using System;

namespace debug
{
    class Program
    {
        static void Main(string[] args)
        {
            ProgramC a = new ProgramC();
            a.main();

        }
    }

    //ABC077
    class ProgramA
    {
        public void main()
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }

    class ProgramB
    {
        public void main()
        {
            long n = long.Parse(Console.ReadLine());
            for (long i = 1; i < 100000; i++)
            {
                if (i * i > n)
                {
                    Console.WriteLine((i - 1) * (i - 1));
                    return;
                }

            }
        }
    }

    //ABC162
    class ProgramC
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());
            long[] a = new long[n];
            long[] b = new long[n];
            long[] c = new long[n];

            string[] s1 = Console.ReadLine().Split(' ');
            string[] s2 = Console.ReadLine().Split(' ');
            string[] s3 = Console.ReadLine().Split(' ');

            for (int i = 0; i < n; i++)
            {
                a[i] = long.Parse(s1[i]);
                b[i] = long.Parse(s2[i]);
                c[i] = long.Parse(s3[i]);
            }

            if (n == 1)
            {
                if (a[0] < b[0] && b[0] < c[0])
                    Console.WriteLine(1);
                else
                    Console.WriteLine(0);
                return;
            }

            //ソートする
            Array.Sort(a);
            Array.Sort(b);
            Array.Sort(c);
            long ans = 0;

            for (int i = 0; i < n; i++)
            {
                //aの二分探索(bより小さいものを探す）
                long ans1 = 0;

                if (a[0] > b[i])
                    continue;


                long min = -1;
                long max = n;

                if (a[n - 1] < b[i])
                {
                    ans1 = n;
                }
                else
                {
                    while(min + 1 != max)
                    {
                        long temp = (max + min) / 2;
                        if (a[temp] < b[i])
                            min = temp;
                        else
                            max = temp;
                    }

                    ans1 = min + 1;
                }

                //cの二分探索（bより大きいものを探す）
                long ans2 = 0;

                if (c[n - 1] < b[i])
                    continue;

                if (c[0] > b[i])
                {
                    ans2 = n;
                }
                else
                {
                    min = -1;
                    max = n;

                    while (min + 1 != max) 
                    {
                        long temp = (max + min) / 2;
                        if (c[temp] > b[i])
                            max = temp;
                        else
                            min = temp;

                    }
                    
                    ans2 = n - max;
                }
                //答えを足す
                ans += ans1 * ans2;

            }

            Console.WriteLine(ans);
        }
    }



    class ProgramD
    {
        static long[] dp;
        static long[] p;
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long x = long.Parse(s[1]);

            //あらかじめ層の数とパティの数は数えておく
            dp = new long[n + 1];
            p = new long[n + 1];
            dp[0] = 1;
            p[0] = 1;
            for (int i = 0; i < n; i++)
            {
                dp[i + 1] = 3 + 2 * dp[i];
                p[i + 1] = 1 + 2 * p[i];
            }

            Console.WriteLine(dfs(n, x));
        }

        /*再帰関数で把握（レベルnのバーガーの下からx番目までにあるパティの数)*/
        static long dfs(long n, long x)
        {
            if (n == 0)
            {
                if (x >= 1)
                    return 1;
                else
                    return 0;
            }
            else if (x <= 1 + dp[n - 1])
                return dfs(n - 1, x - 1);
            else
                return p[n - 1] + 1 + dfs(n - 1, x - 2 - dp[n - 1]);

        }
    }


}


Measured memory_bytes: 46032