from bisect import bisect_left,bisect

N = int(eval(input()))

info = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0

for j in range(N):

    small = bisect_left(info[0],info[1][j])

    large = N - bisect(info[2],info[1][j])

    ans += small * large

print(ans)
from bisect import bisect,bisect_left



N = int(eval(input()))

A = sorted(list(map(int,input().split())))

B = sorted(list(map(int,input().split())))

C = sorted(list(map(int,input().split())))



ans = 0



for b in B:

    ca = bisect_left(A,b)

    cc = N - bisect(C,b)

    ans += ca*cc



print(ans)
from bisect import bisect_left, bisect

N = int(eval(input()))
info = [sorted(list(map(int, input().split()))) for i in range(3)]
ans = 0
for j in range(N):
    small = bisect_left(info[0], info[1][j])
    large = N - bisect(info[2], info[1][j])
    ans += small * large
print(ans)

from bisect import bisect, bisect_left

N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
    ca = bisect_left(A, b)
    cc = N - bisect(C, b)
    ans += ca * cc
print(ans)

-from bisect import bisect_left, bisect +from bisect import bisect, bisect_left -info = [sorted(list(map(int, input().split()))) for i in range(3)] +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) -for j in range(N): -    small = bisect_left(info[0], info[1][j]) -    large = N - bisect(info[2], info[1][j]) -    ans += small * large +for b in B: +    ca = bisect_left(A, b) +    cc = N - bisect(C, b) +    ans += ca * cc