from bisect import bisect_right



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] = N - bisect_right(C, B[i])



cumsum = [0] * (N + 1)

for i in range(N):

    cumsum[i + 1] = cumsum[i] + cnt[N - i - 1]

    

res = 0

for i in range(N):

    res += cumsum[N - bisect_right(B, A[i])]

print(res)





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



from bisect import bisect_left, bisect_right



res = 0

for b in B:

    res += bisect_left(A, b) * (N - bisect_right(C, b))

print(res)

from bisect import bisect_right

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] = N - bisect_right(C, B[i])
cumsum = [0] * (N + 1)
for i in range(N):
    cumsum[i + 1] = cumsum[i] + cnt[N - i - 1]
res = 0
for i in range(N):
    res += cumsum[N - bisect_right(B, A[i])]
print(res)

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())))
from bisect import bisect_left, bisect_right

res = 0
for b in B:
    res += bisect_left(A, b) * (N - bisect_right(C, b))
print(res)

-from bisect import bisect_right - -cnt = [0] * N -for i in range(N): -    cnt[i] = N - bisect_right(C, B[i]) -cumsum = [0] * (N + 1) -for i in range(N): -    cumsum[i + 1] = cumsum[i] + cnt[N - i - 1] +from bisect import bisect_left, bisect_right + -for i in range(N): -    res += cumsum[N - bisect_right(B, A[i])] +for b in B: +    res += bisect_left(A, b) * (N - bisect_right(C, b))