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

for b in B:

    a = bisect.bisect_left(A, b) # 挿入点はどの同じ値よりも左

    c = bisect.bisect_right(C, b) # 挿入点はどの同じ値よりも右

    ans += a * (len(C)-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()



ans = 0



for b in B:

    a = bisect.bisect_left(A, b)

    c = bisect.bisect_right(C, b)

    #print("a:{0},c:{1}".format(a, c))

    ans += a*(len(C)-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()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b)  # 挿入点はどの同じ値よりも左
    c = bisect.bisect_right(C, b)  # 挿入点はどの同じ値よりも右
    ans += a * (len(C) - 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()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    # print("a:{0},c:{1}".format(a, c))
    ans += a * (len(C) - c)
print(ans)

-N = int(eval(input())) +n = int(eval(input())) -    a = bisect.bisect_left(A, b)  # 挿入点はどの同じ値よりも左 -    c = bisect.bisect_right(C, b)  # 挿入点はどの同じ値よりも右 +    a = bisect.bisect_left(A, b) +    c = bisect.bisect_right(C, b) +    # print("a:{0},c:{1}".format(a, c))