import numpy as np

N = int(eval(input()))

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

A.sort()

A = np.array(A)

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

B.sort()

B = np.array(B)

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

C.sort()

C = np.array(C)



ans = 0

for i in range(N):

	b = B[i]

	a_ind = np.searchsorted(A,b,side='left')

	c_ind = np.searchsorted(C,b,side='right')

	ans += a_ind * (N-c_ind)



print(ans)
import numpy as np

N = int(eval(input()))

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

A.sort()

A = np.array(A)

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

B.sort()

B = np.array(B)

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

C.sort()

C = np.array(C)



cnt_A = np.searchsorted(A,B,side='left')

cnt_C = np.searchsorted(C,B,side='right')



ans = (cnt_A * (N-cnt_C)).sum()



print(ans)
import numpy as np

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)
ans = 0
for i in range(N):
    b = B[i]
    a_ind = np.searchsorted(A, b, side="left")
    c_ind = np.searchsorted(C, b, side="right")
    ans += a_ind * (N - c_ind)
print(ans)

import numpy as np

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)
cnt_A = np.searchsorted(A, B, side="left")
cnt_C = np.searchsorted(C, B, side="right")
ans = (cnt_A * (N - cnt_C)).sum()
print(ans)

-ans = 0 -for i in range(N): -    b = B[i] -    a_ind = np.searchsorted(A, b, side="left") -    c_ind = np.searchsorted(C, b, side="right") -    ans += a_ind * (N - c_ind) +cnt_A = np.searchsorted(A, B, side="left") +cnt_C = np.searchsorted(C, B, side="right") +ans = (cnt_A * (N - cnt_C)).sum()