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



cnt_A = np.searchsorted(A,B)

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

ans = (cnt_A*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)
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 = 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()
cnt_A = np.searchsorted(A, B)
cnt_C = N - np.searchsorted(C, B, side="right")
ans = (cnt_A * cnt_C).sum()
print(ans)

-A = list(map(int, input().split())) +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 = np.array(A) -B = list(map(int, input().split())) -B = np.array(B) -C = list(map(int, input().split())) -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() +cnt_A = np.searchsorted(A, B) +cnt_C = N - np.searchsorted(C, B, side="right") +ans = (cnt_A * cnt_C).sum()