# -*- coding: utf-8 -*-





def higher_search(list, key):

    l = -1

    r = len(list)



    while r - l > 1:

        mid = l + (r - l) // 2

        if list[mid] > key:

            r = mid

        else:

            l = mid



    if r == len(list):

        return -1

    else:

        return r





def lower_search(list, key):

    l = -1

    r = len(list)



    while r - l > 1:

        mid = r - (r - l) // 2

        if list[mid] < key:

            l = mid

        else:

            r = mid



    if l == -1:

        return -1

    else:

        return l





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_index = lower_search(A, b)

    c_index = higher_search(C, b)

    if c_index == -1:

        c_index = n

    ans += (a_index + 1) * (n - c_index)



print(ans)

# -*- coding: utf-8 -*-



import bisect



n = int(eval(input()))

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

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

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



ans = 0

for b in B:

    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))

print(ans)

# -*- coding: utf-8 -*-
def higher_search(list, key):
    l = -1
    r = len(list)
    while r - l > 1:
        mid = l + (r - l) // 2
        if list[mid] > key:
            r = mid
        else:
            l = mid
    if r == len(list):
        return -1
    else:
        return r


def lower_search(list, key):
    l = -1
    r = len(list)
    while r - l > 1:
        mid = r - (r - l) // 2
        if list[mid] < key:
            l = mid
        else:
            r = mid
    if l == -1:
        return -1
    else:
        return l


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_index = lower_search(A, b)
    c_index = higher_search(C, b)
    if c_index == -1:
        c_index = n
    ans += (a_index + 1) * (n - c_index)
print(ans)

# -*- coding: utf-8 -*-
import bisect

n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)

-def higher_search(list, key): -    l = -1 -    r = len(list) -    while r - l > 1: -        mid = l + (r - l) // 2 -        if list[mid] > key: -            r = mid -        else: -            l = mid -    if r == len(list): -        return -1 -    else: -        return r - - -def lower_search(list, key): -    l = -1 -    r = len(list) -    while r - l > 1: -        mid = r - (r - l) // 2 -        if list[mid] < key: -            l = mid -        else: -            r = mid -    if l == -1: -        return -1 -    else: -        return l - +import bisect -A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -B.sort() -C.sort() +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) -    a_index = lower_search(A, b) -    c_index = higher_search(C, b) -    if c_index == -1: -        c_index = n -    ans += (a_index + 1) * (n - c_index) +    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))