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:

    l = -1

    r = N

    while r - l > 1:

        m = (r + l) // 2

        if A[m] < b:

            l = m

        else:

            r = m

    a_cnt = l + 1 if l != -1 else 0



    l = -1

    r = N

    while r - l > 1:

        m = (r + l) // 2

        if C[m] > b:

            r = m

        else:

            l = m

    c_cnt = N - r



    ans += a_cnt * c_cnt



print(ans)

import sys



input = sys.stdin.readline



N = int(eval(input()))

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

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

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





def count_a(A, X):

    l = -1

    r = N

    while r - l > 1:

        m = (r + l) // 2

        if A[m] < b:

            l = m

        else:

            r = m

    return l + 1





def count_c(C, X):

    l = -1

    r = N

    while r - l > 1:

        m = (r + l) // 2

        if C[m] > b:

            r = m

        else:

            l = m

    return N - r





A.sort()

B.sort()

C.sort()



ans = 0

A_min = A[0]

C_max = C[-1]



for b in B:

    if b <= A_min or b >= C_max:

        continue



    a_cnt = count_a(A, b)

    if a_cnt == 0:

        continue

    c_cnt = count_c(C, b)



    ans += a_cnt * c_cnt



print(ans)

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:
    l = -1
    r = N
    while r - l > 1:
        m = (r + l) // 2
        if A[m] < b:
            l = m
        else:
            r = m
    a_cnt = l + 1 if l != -1 else 0
    l = -1
    r = N
    while r - l > 1:
        m = (r + l) // 2
        if C[m] > b:
            r = m
        else:
            l = m
    c_cnt = N - r
    ans += a_cnt * c_cnt
print(ans)

import sys

input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


def count_a(A, X):
    l = -1
    r = N
    while r - l > 1:
        m = (r + l) // 2
        if A[m] < b:
            l = m
        else:
            r = m
    return l + 1


def count_c(C, X):
    l = -1
    r = N
    while r - l > 1:
        m = (r + l) // 2
        if C[m] > b:
            r = m
        else:
            l = m
    return N - r


A.sort()
B.sort()
C.sort()
ans = 0
A_min = A[0]
C_max = C[-1]
for b in B:
    if b <= A_min or b >= C_max:
        continue
    a_cnt = count_a(A, b)
    if a_cnt == 0:
        continue
    c_cnt = count_c(C, b)
    ans += a_cnt * c_cnt
print(ans)

+import sys + +input = sys.stdin.readline -A.sort() -B.sort() -C.sort() -ans = 0 -for b in B: + + +def count_a(A, X): -    a_cnt = l + 1 if l != -1 else 0 +    return l + 1 + + +def count_c(C, X): -    c_cnt = N - r +    return N - r + + +A.sort() +B.sort() +C.sort() +ans = 0 +A_min = A[0] +C_max = C[-1] +for b in B: +    if b <= A_min or b >= C_max: +        continue +    a_cnt = count_a(A, b) +    if a_cnt == 0: +        continue +    c_cnt = count_c(C, b)