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 i in range(N):

    a = bisect.bisect_left(A, B[i])

    c = bisect.bisect_right(C, B[i])

    ans += a*(N-c)



print(ans)

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

b.sort()

c.sort()



ans = 0

for i in range(n):

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



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 i in range(N):
    a = bisect.bisect_left(A, B[i])
    c = bisect.bisect_right(C, B[i])
    ans += a * (N - c)
print(ans)

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()
b.sort()
c.sort()
ans = 0
for i in range(n):
    ans += bisect_left(a, b[i]) * (n - bisect_right(c, b[i]))
print(ans)

-import bisect +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() -B.sort() -C.sort() +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() -for i in range(N): -    a = bisect.bisect_left(A, B[i]) -    c = bisect.bisect_right(C, B[i]) -    ans += a * (N - c) +for i in range(n): +    ans += bisect_left(a, b[i]) * (n - bisect_right(c, b[i]))