import bisect

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:

    ai = bisect.bisect_left(A, b)

    ci = bisect.bisect_right(C, b)

    ans += ai * (N-ci)

    #print(b,ai,ci)



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



ans = 0

from bisect import bisect_left, bisect_right

for b in B:

    ac = bisect_left(A,b)

    cc = N - bisect_right(C,b)

    ans += ac * cc

print(ans)
import bisect

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:
    ai = bisect.bisect_left(A, b)
    ci = bisect.bisect_right(C, b)
    ans += ai * (N - ci)
    # print(b,ai,ci)
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()
ans = 0
from bisect import bisect_left, bisect_right

for b in B:
    ac = bisect_left(A, b)
    cc = N - bisect_right(C, b)
    ans += ac * cc
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 +from bisect import bisect_left, bisect_right -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 -    ai = bisect.bisect_left(A, b) -    ci = bisect.bisect_right(C, b) -    ans += ai * (N - ci) -    # print(b,ai,ci) +    ac = bisect_left(A, b) +    cc = N - bisect_right(C, b) +    ans += ac * cc