import bisect

N = int(eval(input()))

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

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

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

A.sort()

B.sort()

C.sort()



cnt = 0 

for j in range(N):

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

  k = bisect.bisect_right(C, B[j])

  cnt += i * (N - k)

  

print(cnt)
from bisect import bisect,bisect_left

N=int(eval(input()))

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

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

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

ans=0

for b in B:

  i=bisect_left(A,b)

  j=bisect(C,b)

  ans+=i*(N-j)

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()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in range(N):
    i = bisect.bisect_left(A, B[j])
    k = bisect.bisect_right(C, B[j])
    cnt += i * (N - k)
print(cnt)

from bisect import bisect, bisect_left

N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
    i = bisect_left(A, b)
    j = bisect(C, b)
    ans += i * (N - j)
print(ans)

-import bisect +from bisect import bisect, bisect_left -A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -B.sort() -C.sort() -cnt = 0 -for j in range(N): -    i = bisect.bisect_left(A, B[j]) -    k = bisect.bisect_right(C, B[j]) -    cnt += i * (N - k) -print(cnt) +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) +ans = 0 +for b in B: +    i = bisect_left(A, b) +    j = bisect(C, b) +    ans += i * (N - j) +print(ans)