n = int(eval(input()))

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

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

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



a.sort()

b.sort()

c.sort()



ans = 0

i = []

k = []

for j in range(n):

    left = n - 1

    right = 0

    a_mid = n // 2

    while left >= right:

        if a[a_mid] >= b[j]:

            left = a_mid - 1

        else:

            right = a_mid + 1

        a_mid = (left + right) // 2

    i.append(a_mid + 1)

    

for j in range(n):

    left = n - 1

    right = 0

    c_mid = n // 2

    while left >= right:

        if c[c_mid] > b[j]:

            left = c_mid - 1

        else:

            right = c_mid + 1

        c_mid = (left + right) // 2

    k.append(n - c_mid - 1)



ans = sum(x * y for x, y in zip(i, k))

print(ans)
import bisect



n = int(eval(input()))

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

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

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



a.sort()

b.sort()

c.sort()



ans = 0

for j in range(n):

    i = bisect.bisect_left(a, b[j])

    k = n - bisect.bisect_right(c, b[j])

    ans += i * k

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
i = []
k = []
for j in range(n):
    left = n - 1
    right = 0
    a_mid = n // 2
    while left >= right:
        if a[a_mid] >= b[j]:
            left = a_mid - 1
        else:
            right = a_mid + 1
        a_mid = (left + right) // 2
    i.append(a_mid + 1)
for j in range(n):
    left = n - 1
    right = 0
    c_mid = n // 2
    while left >= right:
        if c[c_mid] > b[j]:
            left = c_mid - 1
        else:
            right = c_mid + 1
        c_mid = (left + right) // 2
    k.append(n - c_mid - 1)
ans = sum(x * y for x, y in zip(i, k))
print(ans)

import bisect

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for j in range(n):
    i = bisect.bisect_left(a, b[j])
    k = n - bisect.bisect_right(c, b[j])
    ans += i * k
print(ans)

+import bisect + -i = [] -k = [] -    left = n - 1 -    right = 0 -    a_mid = n // 2 -    while left >= right: -        if a[a_mid] >= b[j]: -            left = a_mid - 1 -        else: -            right = a_mid + 1 -        a_mid = (left + right) // 2 -    i.append(a_mid + 1) -for j in range(n): -    left = n - 1 -    right = 0 -    c_mid = n // 2 -    while left >= right: -        if c[c_mid] > b[j]: -            left = c_mid - 1 -        else: -            right = c_mid + 1 -        c_mid = (left + right) // 2 -    k.append(n - c_mid - 1) -ans = sum(x * y for x, y in zip(i, k)) +    i = bisect.bisect_left(a, b[j]) +    k = n - bisect.bisect_right(c, b[j]) +    ans += i * k