from itertools import accumulate
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0] + list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)

a6a66546fbf1e97dadcab9b1e2bd388ae368a22b
<mask token>

<mask token>
b.sort()
c.sort()
<mask token>
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
<mask token>
for j in ai:
    ans += c[j]
print(ans)

<mask token>
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0] + list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)

from itertools import accumulate
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0] + list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)
