import bisect

n = int(eval(input()))

bb = [0] * (n+1)

ans = 0

a = [int(i) for i in input().split()]

b = [int(i) for i in input().split()]

c = [int(i) for i in input().split()]

a.sort()

b.sort()

c.sort()



for i in range(1,n+1):

    bb[i] = bisect.bisect_left(a,b[i-1]) + bb[i-1]



for i in range(n):

    ans += bb[bisect.bisect_left(b,c[i])]

print(ans)
import bisect

n = int(eval(input()))

ans = 0

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

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

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

a.sort()

b.sort()

c.sort()

for i in range(n):

    ans += bisect.bisect_left(a,b[i]) * (n-bisect.bisect_right(c,b[i]))

print(ans)
import bisect

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

import bisect

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

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