Imports System
Imports System.Collections.Generic
Public Class Test
	Public Shared Sub Main()
        Dim n As Integer
        Dim AA As String
        Dim BB As String
        Dim CC As String
        Dim AAA As String()
        Dim BBB As String()
        Dim CCC As String()
        n = Console.ReadLine()
        AA = Console.ReadLine()
        BB = Console.ReadLine()
        CC = Console.ReadLine()
        AAA = AA.Split(" "c)
        BBB = BB.Split(" "c)
        CCC = CC.Split(" "c)
        Dim A As List(Of Integer) = New List(Of Integer)
        Dim B As List(Of Integer) = New List(Of Integer)
        Dim C As List(Of Integer) = New List(Of Integer)
        For Each ai As String In AAA
            A.Add(ai)
        Next
        For Each bi As String In BBB
            B.Add(bi)
        Next
        For Each ci As String In CCC
            C.Add(ci)
        Next
        A.Sort()
        C.Sort()
        Dim count As Integer = 0
        Dim BCcount(n - 1) As Integer
        Dim ABcount(n - 1) As Integer
        For i As Integer = 0 To n - 1
            Dim Pst, Pfi, Qst, Qfi As Integer
            Pst = 0
            Pfi = n - 1
            Qst = 0
            Qfi = n - 1
            If A(n - 1) < B(i) Then
                Pst = n - 1
            ElseIf A(0) > B(i) Then
                Pst = 0
            Else
                Do
                    If (A((Pst + Pfi) \ 2) < B(i)) Then
                        Pst = (Pst + Pfi) \ 2
                    ElseIf (A((Pst + Pfi) \ 2) > B(i)) Then
                        Pfi = (Pst + Pfi) \ 2
                    Else
                        For k As Integer = ((Pst + Pfi) \ 2) To 0 Step -1
                            If (A(k) < B(i) AndAlso A(k + 1) = B(i)) Then
                                Pst = k
                                Pfi = k + 1
                                Exit For
                            End If
                        Next k
                    End If
                    If Pfi = Pst + 1 Then
                        Exit Do
                    End If
                Loop
            End If
            ABcount(i) = Pst + 1
            If C(0) > B(i) Then
                Qst = -1
            ElseIf C(n - 1) < B(i) Then
                Qst = n - 1
            Else
                Do
                    If (C((Qst + Qfi) \ 2) < B(i)) Then
                        Qst = (Qst + Qfi) \ 2
                    ElseIf (C((Qst + Qfi) \ 2) > B(i)) Then
                        Qfi = (Qst + Qfi) \ 2
                    Else
                        For k As Integer = ((Qst + Qfi) \ 2) To n - 1
                            If (C(k) > B(i) AndAlso C(k - 1) = B(i)) Then
                                Qst = k - 1
                                Qfi = k
                                Exit For
                            End If
                        Next k
                    End If
                    If Qfi = Qst + 1 Then
                        Exit Do
                    End If
                Loop
            End If
            BCcount(i) = n - Qst - 1
            count += ABcount(i) * BCcount(i)
        Next i
        Console.WriteLine(count)
	End Sub
End Class