import bisect

N=int(eval(input()))

A=list(map(int,input().split()))

B=list(map(int,input().split()))

C=list(map(int,input().split()))



ans=0

A.sort()

B.sort()

C.sort()



for i in range(len(B)):

    ans+=bisect.bisect_left(A,B[i])*(len(C)-bisect.bisect_right(C,B[i]))

print(ans)
N=int(eval(input()))

A=list(map(int,input().split()))

B=list(map(int,input().split()))

C=list(map(int,input().split()))

#print(A)

A.sort()

B.sort()

C.sort()

#print(A)

import bisect



ans=0

for i in range(N):

    cnt=bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i]))

    ans+=cnt

print(ans)
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
A.sort()
B.sort()
C.sort()
for i in range(len(B)):
    ans += bisect.bisect_left(A, B[i]) * (len(C) - bisect.bisect_right(C, B[i]))
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# print(A)
A.sort()
B.sort()
C.sort()
# print(A)
import bisect

ans = 0
for i in range(N):
    cnt = bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i]))
    ans += cnt
print(ans)

-import bisect - -ans = 0 +# print(A) -for i in range(len(B)): -    ans += bisect.bisect_left(A, B[i]) * (len(C) - bisect.bisect_right(C, B[i])) +# print(A) +import bisect + +ans = 0 +for i in range(N): +    cnt = bisect.bisect_left(A, B[i]) * (N - bisect.bisect_right(C, B[i])) +    ans += cnt