import bisect

N = int(eval(input()))

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

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

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

check = [0] * N

ans = 0

for i in range(N):

    check[i] = N - bisect.bisect_right(C,B[i])

for i in range(1,N):

    check[N-1-i] += check[N-i]

for i in range(N):

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

    if b == N:

        continue

    ans += check[b]

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

cnt = [0]*N

for i in range(N):

    cnt[i] = cnt[i-1] + bisect.bisect_left(A,B[i])

ans = 0

for i in range(N):

    target = bisect.bisect_left(B,C[i])

    if target > 0:

        ans += cnt[target-1]

print(ans)
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
check = [0] * N
ans = 0
for i in range(N):
    check[i] = N - bisect.bisect_right(C, B[i])
for i in range(1, N):
    check[N - 1 - i] += check[N - i]
for i in range(N):
    b = bisect.bisect_right(B, A[i])
    if b == N:
        continue
    ans += check[b]
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())))
cnt = [0] * N
for i in range(N):
    cnt[i] = cnt[i - 1] + bisect.bisect_left(A, B[i])
ans = 0
for i in range(N):
    target = bisect.bisect_left(B, C[i])
    if target > 0:
        ans += cnt[target - 1]
print(ans)

-A = list(map(int, input().split())) +A = sorted(list(map(int, input().split()))) -check = [0] * N +cnt = [0] * N +for i in range(N): +    cnt[i] = cnt[i - 1] + bisect.bisect_left(A, B[i]) -    check[i] = N - bisect.bisect_right(C, B[i]) -for i in range(1, N): -    check[N - 1 - i] += check[N - i] -for i in range(N): -    b = bisect.bisect_right(B, A[i]) -    if b == N: -        continue -    ans += check[b] +    target = bisect.bisect_left(B, C[i]) +    if target > 0: +        ans += cnt[target - 1]