from bisect import bisect

from collections import deque



N = int(eval(input()))

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

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

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



BC_ruiseki = deque([0])

for i, b in enumerate(B):

  BC_ruiseki.append(BC_ruiseki[i] + N - bisect(C, b))



ans = 0

for a in A:

  idx = bisect(B, a)

  ans += BC_ruiseki[-1] - BC_ruiseki[idx]

print(ans)
import bisect



N = int(eval(input()))

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

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

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



ans = 0

for b in B:

  a = bisect.bisect_left(A, b)

  c = N-bisect.bisect(C, b)

  ans += a*c

print(ans)
from bisect import bisect
from collections import deque

N = int(eval(input()))
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
BC_ruiseki = deque([0])
for i, b in enumerate(B):
    BC_ruiseki.append(BC_ruiseki[i] + N - bisect(C, b))
ans = 0
for a in A:
    idx = bisect(B, a)
    ans += BC_ruiseki[-1] - BC_ruiseki[idx]
print(ans)

import bisect

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

-from bisect import bisect -from collections import deque +import bisect -A = list(map(int, input().split())) -B = sorted(list(map(int, input().split()))) +A = sorted(list(map(int, input().split()))) +B = list(map(int, input().split())) -BC_ruiseki = deque([0]) -for i, b in enumerate(B): -    BC_ruiseki.append(BC_ruiseki[i] + N - bisect(C, b)) -for a in A: -    idx = bisect(B, a) -    ans += BC_ruiseki[-1] - BC_ruiseki[idx] +for b in B: +    a = bisect.bisect_left(A, b) +    c = N - bisect.bisect(C, b) +    ans += a * c