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



#print(A)

#print(B)

#print(C)



ans = 0

for b in B:

    a = bisect.bisect_right(A, b-1)

    c = N - bisect.bisect_right(C, b)

    #print("smaller",a,"bigger",c)

    ans += a*c



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



ans = 0

for b in B:

    a = bisect.bisect_right(A, b-1)

    c = len(C)-bisect.bisect_right(C, b)

    ans += a*c

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()
# print(A)
# print(B)
# print(C)
ans = 0
for b in B:
    a = bisect.bisect_right(A, b - 1)
    c = N - bisect.bisect_right(C, b)
    # print("smaller",a,"bigger",c)
    ans += a * c
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()
ans = 0
for b in B:
    a = bisect.bisect_right(A, b - 1)
    c = len(C) - bisect.bisect_right(C, b)
    ans += a * c
print(ans)

-N = int(eval(input())) +n = int(eval(input())) -B.sort() -# print(A) -# print(B) -# print(C) -    c = N - bisect.bisect_right(C, b) -    # print("smaller",a,"bigger",c) +    c = len(C) - bisect.bisect_right(C, b)