N = int(eval(input()))

A = [int(a) for a in input().split()]

B = [int(b) for b in input().split()]

C = [int(c) for c in input().split()]



A_sorted = sorted(A)

B_sorted = sorted(B)

C_sorted = sorted(C)



ans = 0

for b in B_sorted:

    #Aのうちbより小さいの数

    left = -1

    right = N 

    while right - left > 1:

        mid = left + (right - left) // 2

        if A_sorted[mid] < b:

            left = mid

        else:

            right = mid

    a_count = right

    #Cのうちbより大きいの数

    left = -1

    right = N 

    while right - left > 1:

        mid = left + (right - left) // 2

        if C_sorted[mid] > b:

            right = mid

        else:

            left = mid

    c_count = N - right

    

    ans += a_count * c_count



print(ans)
import bisect

N = int(eval(input()))

A = [int(a) for a in input().split()]

B = [int(b) for b in input().split()]

C = [int(c) for c in input().split()]



A_sorted = sorted(A)

B_sorted = sorted(B)

C_sorted = sorted(C)



ans = 0

for b in B_sorted:

    #Aのうちbより小さいの数

    a_count = bisect.bisect_left(A_sorted, b)

    

    #Cのうちbより大きいの数

    c_count = N - bisect.bisect_right(C_sorted, b)

    

    ans += a_count * c_count



print(ans)
N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A_sorted = sorted(A)
B_sorted = sorted(B)
C_sorted = sorted(C)
ans = 0
for b in B_sorted:
    # Aのうちbより小さいの数
    left = -1
    right = N
    while right - left > 1:
        mid = left + (right - left) // 2
        if A_sorted[mid] < b:
            left = mid
        else:
            right = mid
    a_count = right
    # Cのうちbより大きいの数
    left = -1
    right = N
    while right - left > 1:
        mid = left + (right - left) // 2
        if C_sorted[mid] > b:
            right = mid
        else:
            left = mid
    c_count = N - right
    ans += a_count * c_count
print(ans)

import bisect

N = int(eval(input()))
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A_sorted = sorted(A)
B_sorted = sorted(B)
C_sorted = sorted(C)
ans = 0
for b in B_sorted:
    # Aのうちbより小さいの数
    a_count = bisect.bisect_left(A_sorted, b)
    # Cのうちbより大きいの数
    c_count = N - bisect.bisect_right(C_sorted, b)
    ans += a_count * c_count
print(ans)

+import bisect + -    left = -1 -    right = N -    while right - left > 1: -        mid = left + (right - left) // 2 -        if A_sorted[mid] < b: -            left = mid -        else: -            right = mid -    a_count = right +    a_count = bisect.bisect_left(A_sorted, b) -    left = -1 -    right = N -    while right - left > 1: -        mid = left + (right - left) // 2 -        if C_sorted[mid] > b: -            right = mid -        else: -            left = mid -    c_count = N - right +    c_count = N - bisect.bisect_right(C_sorted, b)