import numpy as np

import sys

input = sys.stdin.readline

 

N = int(eval(input()))

A = np.array(input().split(), dtype=np.int64)

B = np.array(input().split(), dtype=np.int64)

C = np.array(input().split(), dtype=np.int64)



A.sort()

C.sort()



ans = 0

for i in range(N):

	b = B[i]

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

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

	ans += A_cnt * (N-C_cnt)



print(ans)
import numpy as np

import sys

input = sys.stdin.readline

 

N = int(eval(input()))

A = np.array(input().split(), dtype=np.int64)

B = np.array(input().split(), dtype=np.int64)

C = np.array(input().split(), dtype=np.int64)



A.sort()

C.sort()



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

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



ans = (A_cnt * (N-C_cnt)).sum()



print(ans)
import numpy as np
import sys

input = sys.stdin.readline
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.array(input().split(), dtype=np.int64)
A.sort()
C.sort()
ans = 0
for i in range(N):
    b = B[i]
    A_cnt = np.searchsorted(A, b, side="left")
    C_cnt = np.searchsorted(C, b, side="right")
    ans += A_cnt * (N - C_cnt)
print(ans)

import numpy as np
import sys

input = sys.stdin.readline
N = int(eval(input()))
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)
C = np.array(input().split(), dtype=np.int64)
A.sort()
C.sort()
A_cnt = np.searchsorted(A, B, side="left")
C_cnt = np.searchsorted(C, B, side="right")
ans = (A_cnt * (N - C_cnt)).sum()
print(ans)

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