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

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

+B.sort()