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

C.sort()

ct = 0

for j in B:

    a_max = bisect.bisect_left(A, j)

    c_min = bisect.bisect_right(C, j)

    ct += a_max * (n - c_min)

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

C.sort()



ans = 0



for b in B:

    a_max = bisect.bisect_left(A, b)

    c_min = bisect.bisect_right(C ,b)

    ans += a_max * (n - c_min)

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()
C.sort()
ct = 0
for j in B:
    a_max = bisect.bisect_left(A, j)
    c_min = bisect.bisect_right(C, j)
    ct += a_max * (n - c_min)
print(ct)

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()
C.sort()
ans = 0
for b in B:
    a_max = bisect.bisect_left(A, b)
    c_min = bisect.bisect_right(C, b)
    ans += a_max * (n - c_min)
print(ans)

-ct = 0 -for j in B: -    a_max = bisect.bisect_left(A, j) -    c_min = bisect.bisect_right(C, j) -    ct += a_max * (n - c_min) -print(ct) +ans = 0 +for b in B: +    a_max = bisect.bisect_left(A, b) +    c_min = bisect.bisect_right(C, b) +    ans += a_max * (n - c_min) +print(ans)