from bisect import *

n = int(eval(input()))

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

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

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



a = sorted(a)

c = sorted(c)



rec = 0

for i in range(n):

    temp = b[i]

    l = bisect_left(a, temp)

    r = bisect_right(c, temp)

    rec += l * (n - r)

print(rec)
from bisect import *

n = int(eval(input()))

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

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

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



a.sort()

c.sort()

res = 0

for i in b:

    temp_a = bisect_left(a, i)

    temp_c = n - bisect_right(c, i)

    res += temp_a*temp_c

print(res)
from bisect import *

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = sorted(a)
c = sorted(c)
rec = 0
for i in range(n):
    temp = b[i]
    l = bisect_left(a, temp)
    r = bisect_right(c, temp)
    rec += l * (n - r)
print(rec)

from bisect import *

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
res = 0
for i in b:
    temp_a = bisect_left(a, i)
    temp_c = n - bisect_right(c, i)
    res += temp_a * temp_c
print(res)

-a = sorted(a) -c = sorted(c) -rec = 0 -for i in range(n): -    temp = b[i] -    l = bisect_left(a, temp) -    r = bisect_right(c, temp) -    rec += l * (n - r) -print(rec) +a.sort() +c.sort() +res = 0 +for i in b: +    temp_a = bisect_left(a, i) +    temp_c = n - bisect_right(c, i) +    res += temp_a * temp_c +print(res)