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()



import bisect



ans = 0

for j in range(n):

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

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

    ans += i * (n - k)



print(ans)

from bisect import bisect_left

from itertools import accumulate



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()



ba_cnt = [bisect_left(a, e) for e in b]

ba_acm = [0] + list(accumulate(ba_cnt))



ans = 0

for e in c:

    i = bisect_left(b, e)

    ans += ba_acm[i]



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()
import bisect

ans = 0
for j in range(n):
    i = bisect.bisect_left(a, b[j])
    k = bisect.bisect_right(c, b[j])
    ans += i * (n - k)
print(ans)

from bisect import bisect_left
from itertools import accumulate

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()
ba_cnt = [bisect_left(a, e) for e in b]
ba_acm = [0] + list(accumulate(ba_cnt))
ans = 0
for e in c:
    i = bisect_left(b, e)
    ans += ba_acm[i]
print(ans)

+from bisect import bisect_left +from itertools import accumulate + -import bisect - +ba_cnt = [bisect_left(a, e) for e in b] +ba_acm = [0] + list(accumulate(ba_cnt)) -for j in range(n): -    i = bisect.bisect_left(a, b[j]) -    k = bisect.bisect_right(c, b[j]) -    ans += i * (n - k) +for e in c: +    i = bisect_left(b, e) +    ans += ba_acm[i]