import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



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:

    num_a = bisect.bisect_left(A, b)

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



    ans += num_a * num_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:

    i = bisect.bisect_left(A, b)

    j = bisect.bisect_right(C, b)

    ans += i * (N - j)



print(ans)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
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:
    num_a = bisect.bisect_left(A, b)
    num_c = N - bisect.bisect_right(C, b)
    ans += num_a * num_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:
    i = bisect.bisect_left(A, b)
    j = bisect.bisect_right(C, b)
    ans += i * (N - j)
print(ans)

-import sys - -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -    num_a = bisect.bisect_left(A, b) -    num_c = N - bisect.bisect_right(C, b) -    ans += num_a * num_c +    i = bisect.bisect_left(A, b) +    j = bisect.bisect_right(C, b) +    ans += i * (N - j)