import bisect



N=int(eval(input()))

A=[int(x) for x in input().split()]

B=[int(x) for x in input().split()]

C=[int(x) for x in input().split()]



A.sort()

B.sort()

C.sort()

ans=0

for i in range(N):

  a=bisect.bisect_right(C,B[i])

  b=bisect.bisect_left(A,B[i])

  ans+=(N-a)*b

print(ans)
import bisect



N=int(eval(input()))

A=[int(x) for x in input().split()]

B=[int(x) for x in input().split()]

C=[int(x) for x in input().split()]



A.sort()

B.sort()

C.sort()



ans=0



for i in range(N):

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



print(ans)
import bisect

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

import bisect

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

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