import bisect

from itertools import accumulate

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

b_to_c = [0]*n

for i in range(n):

  b_to_c[i] = n - bisect.bisect_right(C, B[i])

Q = list(accumulate(b_to_c[::-1]))[::-1]

  

for i in A:

  t = bisect.bisect_right(B, i)

  if t < n:

    ans += Q[t]

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 i in B:

  ans += bisect.bisect_left(A, i) * (n - bisect.bisect_right(C, i))

print(ans)
import bisect
from itertools import accumulate

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
b_to_c = [0] * n
for i in range(n):
    b_to_c[i] = n - bisect.bisect_right(C, B[i])
Q = list(accumulate(b_to_c[::-1]))[::-1]
for i in A:
    t = bisect.bisect_right(B, i)
    if t < n:
        ans += Q[t]
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 i in B:
    ans += bisect.bisect_left(A, i) * (n - bisect.bisect_right(C, i))
print(ans)

-from itertools import accumulate -b_to_c = [0] * n -for i in range(n): -    b_to_c[i] = n - bisect.bisect_right(C, B[i]) -Q = list(accumulate(b_to_c[::-1]))[::-1] -for i in A: -    t = bisect.bisect_right(B, i) -    if t < n: -        ans += Q[t] +for i in B: +    ans += bisect.bisect_left(A, i) * (n - bisect.bisect_right(C, i))