import numpy as np

import sys



N = int(eval(input()))

I = np.array(sys.stdin.read().split(), np.int64)

A = I[:N]

B = I[N:2*N]

C = I[2*N:]



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



N = int(eval(input()))

#I = np.array(sys.stdin.read().split(), np.int64)

#A = I[:N]

#B = I[N:2*N]

#C = I[2*N:]



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

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

N = int(eval(input()))
I = np.array(sys.stdin.read().split(), np.int64)
A = I[:N]
B = I[N : 2 * N]
C = I[2 * N :]
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

N = int(eval(input()))
# I = np.array(sys.stdin.read().split(), np.int64)
# A = I[:N]
# B = I[N:2*N]
# C = I[2*N:]
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()
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)

-I = np.array(sys.stdin.read().split(), np.int64) -A = I[:N] -B = I[N : 2 * N] -C = I[2 * N :] +# I = np.array(sys.stdin.read().split(), np.int64) +# A = I[:N] +# B = I[N:2*N] +# C = I[2*N:] +A = np.array(list(map(int, input().split()))) +B = np.array(list(map(int, input().split()))) +C = np.array(list(map(int, input().split())))