import numpy as np

N = int(eval(input()))

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

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

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

A.sort()

B.sort()

C.sort()



ans = 0

for b in B:

    AB = A.searchsorted(b, side='left')

    CB = len(B) - C.searchsorted(b, side='right')

    ans += AB * CB



print(ans)





from bisect import bisect_left, bisect_right

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



ans = 0

for b in B:

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



print(ans)

import numpy as np

N = int(eval(input()))
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))
C = np.array(list(map(int, input().split())))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    AB = A.searchsorted(b, side="left")
    CB = len(B) - C.searchsorted(b, side="right")
    ans += AB * CB
print(ans)

from bisect import bisect_left, bisect_right

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())))
ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C, b))
print(ans)

-import numpy as np +from bisect import bisect_left, bisect_right -A = np.array(list(map(int, input().split()))) -B = np.array(list(map(int, input().split()))) -C = np.array(list(map(int, input().split()))) -A.sort() -B.sort() -C.sort() +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) -    AB = A.searchsorted(b, side="left") -    CB = len(B) - C.searchsorted(b, side="right") -    ans += AB * CB +    ans += bisect_left(A, b) * (N - bisect_right(C, b))