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

C.sort()



ans = 0

mem_idx_a = {}

for idx_b in range(N):

  idx_c = bisect.bisect_right(C,B[idx_b])

  idx_a = bisect.bisect_left(A,B[idx_b])

  ans += (N-idx_c)*idx_a

print(ans)
import bisect



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:

    idx_a = bisect.bisect_left(A, b)

    idx_c = bisect.bisect(C, b)

    ans += idx_a * (N - idx_c)

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()
C.sort()
ans = 0
mem_idx_a = {}
for idx_b in range(N):
    idx_c = bisect.bisect_right(C, B[idx_b])
    idx_a = bisect.bisect_left(A, B[idx_b])
    ans += (N - idx_c) * idx_a
print(ans)

import bisect

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:
    idx_a = bisect.bisect_left(A, b)
    idx_c = bisect.bisect(C, b)
    ans += idx_a * (N - idx_c)
print(ans)

-A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -C.sort() +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) -mem_idx_a = {} -for idx_b in range(N): -    idx_c = bisect.bisect_right(C, B[idx_b]) -    idx_a = bisect.bisect_left(A, B[idx_b]) -    ans += (N - idx_c) * idx_a +for b in B: +    idx_a = bisect.bisect_left(A, b) +    idx_c = bisect.bisect(C, b) +    ans += idx_a * (N - idx_c)