import numpy as np



N = int(input())



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

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

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



A = sorted(A)

B = sorted(B)

C = sorted(C)



ans = 0

x = 0

z = 0



for y in B:

    while x < N and A[x] < y:

        x = x + 1

    while z < N and C[z] <= y:

        z = z + 1

    ans = ans + x*(N-z)

print(ans)

from bisect import bisect_right, bisect_left



N = int(input())



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

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

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



A = sorted(A)

B = sorted(B)

C = sorted(C)



ans = 0

A_on_B = 0

C_under_B = 0

for y in B:

    A_on_B = bisect_left(A, y) 

    C_under_B = N - bisect_right(C, y) 

    ans = ans + A_on_B*C_under_B

print(ans)

import numpy as np

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
x = 0
z = 0
for y in B:
    while x < N and A[x] < y:
        x = x + 1
    while z < N and C[z] <= y:
        z = z + 1
    ans = ans + x * (N - z)
print(ans)

from bisect import bisect_right, bisect_left

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)
ans = 0
A_on_B = 0
C_under_B = 0
for y in B:
    A_on_B = bisect_left(A, y)
    C_under_B = N - bisect_right(C, y)
    ans = ans + A_on_B * C_under_B
print(ans)

-import numpy as np +from bisect import bisect_right, bisect_left -x = 0 -z = 0 +A_on_B = 0 +C_under_B = 0 -    while x < N and A[x] < y: -        x = x + 1 -    while z < N and C[z] <= y: -        z = z + 1 -    ans = ans + x * (N - z) +    A_on_B = bisect_left(A, y) +    C_under_B = N - bisect_right(C, y) +    ans = ans + A_on_B * C_under_B