# 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



import numpy as np

N = int(eval(input()))

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

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

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

A.sort()

C.sort()



ans = np.sum(np.searchsorted(A, B,'left') * (N - np.searchsorted(C, B,'right')))

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
import numpy as np

N = int(eval(input()))
A = np.array(list(int(x) for x in input().split()))
B = np.array(list(int(x) for x in input().split()))
C = np.array(list(int(x) for x in input().split()))
A.sort()
C.sort()
ans = np.sum(np.searchsorted(A, B, "left") * (N - np.searchsorted(C, B, "right")))
print(ans)

-import bisect +import numpy as np -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 = np.array(list(int(x) for x in input().split())) +B = np.array(list(int(x) for x in input().split())) +C = np.array(list(int(x) for x in input().split())) -ans = 0 -for j in range(N): -    ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j])) +ans = np.sum(np.searchsorted(A, B, "left") * (N - np.searchsorted(C, B, "right")))