# C - Snuke Festival



N = int(eval(input()))

A = list(int(x) for x in input().split())

B = list(int(x) for x in input().split())

C = list(int(x) for x in input().split())



A.sort()

C.sort()



def binarySearchLeft(a, b):

    l = -1

    r = N

    while l+1<r:

        m = (l+r)//2

        if a[m]<b:

            l = m

        else:

            r = m

    return r



def binarySearchRight(a, b):

    l = -1

    r = N

    while l+1<r:

        m = (l+r)//2

        if a[m]<=b:

            l = m

        else:

            r = m

    return r



ans = 0

for j in range(N):

    ans += binarySearchLeft(A, B[j]) * (N - binarySearchRight(C, B[j]))



print(ans)
# C - Snuke Festival



import bisect



N = int(eval(input()))

A = list(int(x) for x in input().split())

B = list(int(x) for x in input().split())

C = list(int(x) for x in input().split())



A.sort()

C.sort()



ans = 0

for j in range(N):

    ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j]))



print(ans)
# C - Snuke Festival
N = int(eval(input()))
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())
A.sort()
C.sort()


def binarySearchLeft(a, b):
    l = -1
    r = N
    while l + 1 < r:
        m = (l + r) // 2
        if a[m] < b:
            l = m
        else:
            r = m
    return r


def binarySearchRight(a, b):
    l = -1
    r = N
    while l + 1 < r:
        m = (l + r) // 2
        if a[m] <= b:
            l = m
        else:
            r = m
    return r


ans = 0
for j in range(N):
    ans += binarySearchLeft(A, B[j]) * (N - binarySearchRight(C, B[j]))
print(ans)

# C - Snuke Festival
import bisect

N = int(eval(input()))
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())
A.sort()
C.sort()
ans = 0
for j in range(N):
    ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j]))
print(ans)

+import bisect + - - -def binarySearchLeft(a, b): -    l = -1 -    r = N -    while l + 1 < r: -        m = (l + r) // 2 -        if a[m] < b: -            l = m -        else: -            r = m -    return r - - -def binarySearchRight(a, b): -    l = -1 -    r = N -    while l + 1 < r: -        m = (l + r) // 2 -        if a[m] <= b: -            l = m -        else: -            r = m -    return r - - -    ans += binarySearchLeft(A, B[j]) * (N - binarySearchRight(C, B[j])) +    ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j]))