N = int(eval(input()))



A = sorted(list(map(int,input().split())))

B = sorted(list(map(int,input().split())))

C = sorted(list(map(int,input().split())))





"""

minnum以上で最小の数のindexを返す。無いときはlen(List)を返す

計算量log(len(List))



def bts(List,minnum,under=0):

    if List[0]>=minnum:

        return under

    if List[-1]<minnum:

        return len(List)+under

    i = int(len(List)/2)

    if List[i]>=minnum and List[i-1]<minnum:

        return i + under

    if List[i]<minnum:

        return bts(List[i+1:],minnum,under+i+1)

    return bts(List[:i],minnum,under)



"""



def binary_search(list, item):

    if list[0]>=item:

        return 0

    if list[-1]<item:

        return len(list)



    low = 0

    high = len(list) - 1



    while low <= high:

        mid = (low + high) //2

        guess = list[mid]

        if guess >= item and list[mid-1] < item:

            return mid

        if guess >= item:

            high = mid -1

        else:

            low = mid + 1



    return None



res = 0

for i in range(N):

    b = B[i]

    a = binary_search(A,b)

    c = N - binary_search(C,b+1)

    res += a*c



print(res)

import bisect

n=int(eval(input()))

al=list(map(int,input().split()))

bl=list(map(int,input().split()))

cl=list(map(int,input().split()))



al.sort()

bl.sort()

cl.sort()



ans=0

for b in bl:

    ac=bisect.bisect_right(al,b-1)

    cc=n-bisect.bisect_left(cl,b+1)

    ans+=ac*cc

print(ans)



N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
"""
minnum以上で最小の数のindexを返す。無いときはlen(List)を返す
計算量log(len(List))
def bts(List,minnum,under=0):
    if List[0]>=minnum:
        return under
    if List[-1]<minnum:
        return len(List)+under
    i = int(len(List)/2)
    if List[i]>=minnum and List[i-1]<minnum:
        return i + under
    if List[i]<minnum:
        return bts(List[i+1:],minnum,under+i+1)
    return bts(List[:i],minnum,under)
"""


def binary_search(list, item):
    if list[0] >= item:
        return 0
    if list[-1] < item:
        return len(list)
    low = 0
    high = len(list) - 1
    while low <= high:
        mid = (low + high) // 2
        guess = list[mid]
        if guess >= item and list[mid - 1] < item:
            return mid
        if guess >= item:
            high = mid - 1
        else:
            low = mid + 1
    return None


res = 0
for i in range(N):
    b = B[i]
    a = binary_search(A, b)
    c = N - binary_search(C, b + 1)
    res += a * c
print(res)

import bisect

n = int(eval(input()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
ans = 0
for b in bl:
    ac = bisect.bisect_right(al, b - 1)
    cc = n - bisect.bisect_left(cl, b + 1)
    ans += ac * cc
print(ans)

-N = int(eval(input())) -A = sorted(list(map(int, input().split()))) -B = sorted(list(map(int, input().split()))) -C = sorted(list(map(int, input().split()))) -""" -minnum以上で最小の数のindexを返す。無いときはlen(List)を返す -計算量log(len(List)) -def bts(List,minnum,under=0): -    if List[0]>=minnum: -        return under -    if List[-1]<minnum: -        return len(List)+under -    i = int(len(List)/2) -    if List[i]>=minnum and List[i-1]<minnum: -        return i + under -    if List[i]<minnum: -        return bts(List[i+1:],minnum,under+i+1) -    return bts(List[:i],minnum,under) -""" +import bisect - -def binary_search(list, item): -    if list[0] >= item: -        return 0 -    if list[-1] < item: -        return len(list) -    low = 0 -    high = len(list) - 1 -    while low <= high: -        mid = (low + high) // 2 -        guess = list[mid] -        if guess >= item and list[mid - 1] < item: -            return mid -        if guess >= item: -            high = mid - 1 -        else: -            low = mid + 1 -    return None - - -res = 0 -for i in range(N): -    b = B[i] -    a = binary_search(A, b) -    c = N - binary_search(C, b + 1) -    res += a * c -print(res) +n = int(eval(input())) +al = list(map(int, input().split())) +bl = list(map(int, input().split())) +cl = list(map(int, input().split())) +al.sort() +bl.sort() +cl.sort() +ans = 0 +for b in bl: +    ac = bisect.bisect_right(al, b - 1) +    cc = n - bisect.bisect_left(cl, b + 1) +    ans += ac * cc +print(ans)