import bisect



N = int(eval(input()))

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

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

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



ans = 0



for i in B:

    ans += (bisect.bisect_left(A, i)) * (N-bisect.bisect_right(C, i))

print(ans)
import bisect



N = int(eval(input()))

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

ans = 0



for i in B:

    num_A = bisect.bisect_left(A, i)

    num_B = bisect.bisect_right(C, i)

    ans += num_A * (N - num_B)



print(ans)
import bisect

N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])
ans = 0
for i in B:
    ans += (bisect.bisect_left(A, i)) * (N - bisect.bisect_right(C, i))
print(ans)

import bisect

N = int(eval(input()))
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()
ans = 0
for i in B:
    num_A = bisect.bisect_left(A, i)
    num_B = bisect.bisect_right(C, i)
    ans += num_A * (N - num_B)
print(ans)

-A = sorted([int(i) for i in input().split()]) -B = sorted([int(i) for i in input().split()]) -C = sorted([int(i) for i in input().split()]) +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() -    ans += (bisect.bisect_left(A, i)) * (N - bisect.bisect_right(C, i)) +    num_A = bisect.bisect_left(A, i) +    num_B = bisect.bisect_right(C, i) +    ans += num_A * (N - num_B)