from bisect import bisect_left



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()



# print(A)

# print(B)

# print(C)



A_B = []



for i in range(n):

    A_B.append(bisect_left(A, B[i]))



ruisekiwa = [A_B[0]]

for i in range(1, n):

    ruisekiwa.append(ruisekiwa[-1] + A_B[i])



# print(A_B)

# print(ruisekiwa)



ans = 0



for i in range(n):

    idx = bisect_left(B, C[i])

    if idx:

        ans += ruisekiwa[idx-1]



print(ans)
from bisect import bisect_left, bisect_right



n = int(eval(input()))

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

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

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



A.sort()

C.sort()



ans = 0



for i in range(n):

    ans += bisect_left(A, B[i]) * (n - bisect_right(C, B[i]))



print(ans)

from bisect import bisect_left

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()
# print(A)
# print(B)
# print(C)
A_B = []
for i in range(n):
    A_B.append(bisect_left(A, B[i]))
ruisekiwa = [A_B[0]]
for i in range(1, n):
    ruisekiwa.append(ruisekiwa[-1] + A_B[i])
# print(A_B)
# print(ruisekiwa)
ans = 0
for i in range(n):
    idx = bisect_left(B, C[i])
    if idx:
        ans += ruisekiwa[idx - 1]
print(ans)

from bisect import bisect_left, bisect_right

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

-from bisect import bisect_left +from bisect import bisect_left, bisect_right -B.sort() -# print(A) -# print(B) -# print(C) -A_B = [] -for i in range(n): -    A_B.append(bisect_left(A, B[i])) -ruisekiwa = [A_B[0]] -for i in range(1, n): -    ruisekiwa.append(ruisekiwa[-1] + A_B[i]) -# print(A_B) -# print(ruisekiwa) -    idx = bisect_left(B, C[i]) -    if idx: -        ans += ruisekiwa[idx - 1] +    ans += bisect_left(A, B[i]) * (n - bisect_right(C, B[i]))