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



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



B = sorted(B * (-1))

C = sorted(C * (-1))



c = np.searchsorted(C, B, side='left')

c = np.fliplr([c])[0]





print(((a * c).sum()))
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()



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

c = np.searchsorted(C, -B, side='left')



print(((a * c).sum()))
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()
a = np.searchsorted(A, B, side="left")
B = sorted(B * (-1))
C = sorted(C * (-1))
c = np.searchsorted(C, B, side="left")
c = np.fliplr([c])[0]
print(((a * c).sum()))

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()
a = np.searchsorted(A, B, side="left")
c = np.searchsorted(C, -B, side="left")
print(((a * c).sum()))

-C = np.array(list(map(int, input().split()))) +C = -np.array(list(map(int, input().split()))) +C.sort() -B = sorted(B * (-1)) -C = sorted(C * (-1)) -c = np.searchsorted(C, B, side="left") -c = np.fliplr([c])[0] +c = np.searchsorted(C, -B, side="left")