from bisect import 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())))



ca = [0] * N

cb = [0] * N



for i in range(N):

  ca[i] = bisect_right(B, A[i])

  cb[i] = N - bisect_right(C, B[i])



cb.append(0)

for i in range(N, 0, -1):

  cb[i-1] += cb[i]



print((sum([cb[i] for i in ca])))
from bisect import bisect_right, bisect_left



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)
from bisect import 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())))
ca = [0] * N
cb = [0] * N
for i in range(N):
    ca[i] = bisect_right(B, A[i])
    cb[i] = N - bisect_right(C, B[i])
cb.append(0)
for i in range(N, 0, -1):
    cb[i - 1] += cb[i]
print((sum([cb[i] for i in ca])))

from bisect import bisect_right, bisect_left

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)

-from bisect import bisect_right +from bisect import bisect_right, bisect_left -ca = [0] * N -cb = [0] * N -for i in range(N): -    ca[i] = bisect_right(B, A[i]) -    cb[i] = N - bisect_right(C, B[i]) -cb.append(0) -for i in range(N, 0, -1): -    cb[i - 1] += cb[i] -print((sum([cb[i] for i in ca]))) +ans = 0 +for b in B: +    ans += bisect_left(A, b) * (N - bisect_right(C, b)) +print(ans)