N = int(eval(input()))

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

#A = [int(x) for x in input().split()]

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

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

A.sort()

A = [-float('inf')] + A + [float('inf')]

B.sort()

C.sort()

C = [-float('inf')] + C + [float('inf')]



total = 0



for i in range(N):

    low = 0

    high = N + 1

    while low + 1 < high:

        mid1 = (low + high) // 2

        if A[mid1] < B[i]:

            low = mid1

        else:

            high = mid1

    mid1 = low

    low = 0

    high = N + 1

    while low + 1 < high:

        mid2 = (low + high) // 2

        if C[mid2] <= B[i]:

            low = mid2

        else:

            high = mid2

    mid2 = high

    total = total + mid1 * (N + 1 - mid2)



print(total)
import bisect

N = int(eval(input()))

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

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

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

A.sort()

B.sort()

C.sort()

ans = 0

for b in B:

    ans += bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))

print(ans)
N = int(eval(input()))
A = list(map(int, input().split()))
# A = [int(x) for x in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
A = [-float("inf")] + A + [float("inf")]
B.sort()
C.sort()
C = [-float("inf")] + C + [float("inf")]
total = 0
for i in range(N):
    low = 0
    high = N + 1
    while low + 1 < high:
        mid1 = (low + high) // 2
        if A[mid1] < B[i]:
            low = mid1
        else:
            high = mid1
    mid1 = low
    low = 0
    high = N + 1
    while low + 1 < high:
        mid2 = (low + high) // 2
        if C[mid2] <= B[i]:
            low = mid2
        else:
            high = mid2
    mid2 = high
    total = total + mid1 * (N + 1 - mid2)
print(total)

import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
print(ans)

+import bisect + -# A = [int(x) for x in input().split()] -A = [-float("inf")] + A + [float("inf")] -C = [-float("inf")] + C + [float("inf")] -total = 0 -for i in range(N): -    low = 0 -    high = N + 1 -    while low + 1 < high: -        mid1 = (low + high) // 2 -        if A[mid1] < B[i]: -            low = mid1 -        else: -            high = mid1 -    mid1 = low -    low = 0 -    high = N + 1 -    while low + 1 < high: -        mid2 = (low + high) // 2 -        if C[mid2] <= B[i]: -            low = mid2 -        else: -            high = mid2 -    mid2 = high -    total = total + mid1 * (N + 1 - mid2) -print(total) +ans = 0 +for b in B: +    ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b)) +print(ans)