import bisect



n = int(eval(input()))

*a, = sorted(map(int, input().split()))

*b, = sorted(map(int, input().split()))

*c, = sorted(map(int, input().split()))



ans = 0

for _b in b:

    aNum = bisect.bisect_left(a, _b)

    cNum = len(c) - bisect.bisect_right(c, _b)

    ans += aNum*cNum



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 _b in b:

    ans += bisect.bisect_left(a, _b)*(n - bisect.bisect_right(c, _b))



print(ans)

import bisect

n = int(eval(input()))
(*a,) = sorted(map(int, input().split()))
(*b,) = sorted(map(int, input().split()))
(*c,) = sorted(map(int, input().split()))
ans = 0
for _b in b:
    aNum = bisect.bisect_left(a, _b)
    cNum = len(c) - bisect.bisect_right(c, _b)
    ans += aNum * cNum
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 _b in b:
    ans += bisect.bisect_left(a, _b) * (n - bisect.bisect_right(c, _b))
print(ans)

-(*a,) = sorted(map(int, input().split())) -(*b,) = sorted(map(int, input().split())) -(*c,) = sorted(map(int, input().split())) +(*a,) = list(map(int, input().split())) +(*b,) = list(map(int, input().split())) +(*c,) = list(map(int, input().split())) +a.sort() +b.sort() +c.sort() -    aNum = bisect.bisect_left(a, _b) -    cNum = len(c) - bisect.bisect_right(c, _b) -    ans += aNum * cNum +    ans += bisect.bisect_left(a, _b) * (n - bisect.bisect_right(c, _b))