#!/usr/bin/env python3

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)
print(f"N: {N}")
print(f"A, B, C: {A}, {B}, {C}")

# def binary_search_lower_bound(arr, value):
#     left = 0
#     right = len(arr) - 1
#     if value <= arr[left]:
#         return left
#     if value >= arr[right]:
#         return right
#     while left <= right:
#         mid = int((left + right) / 2)
#         if value > arr[mid]:
#             left = mid + 1
#         elif value < arr[mid]:
#             right = mid - 1
#         else:
#             return mid
#     # left == right + 1, so arr[right] < value < arr[left]
#     return left

def binary_search_more_than(arr, value):
    left = 0
    right = len(arr) - 1
    if value < arr[left]:
        return left
    if value > arr[right]:
        return right
    while left <= right:
        mid = int((left + right) / 2)
        if value > arr[mid]:
            left = mid + 1
        elif value < arr[mid]:
            right = mid - 1
        else:
            return mid + 1
    # left == right + 1, so arr[right] < value < arr[left]
    return left

count = 0
alters = []
for top in A:
    # print(f"\ntop: {top}")
    index_B = binary_search_more_than(B, top)
    B_bin = B[index_B:]
    # print(f"B_bin: {B_bin}")
    for mid in B_bin:
        # print(f"mid: {mid}")
        index_C = binary_search_more_than(C, mid)
        C_bin = C[index_C:]
        # print(f"C_bin: {C_bin}")
        count += len(C_bin)

print(count)


### FIXED CODE ###

#!/usr/bin/env python3

import bisect

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
# print(f"N: {N}")
# print(f"A, B, C: {A}, {B}, {C}")

def binary_search_more_than(arr, value):
    left = 0
    right = len(arr) - 1
    if value < arr[left]:
        return left
    if value > arr[right]:
        return None
    while left <= right:
        mid = int((left + right) / 2)
        if value > arr[mid]:
            left = mid + 1
        elif value < arr[mid]:
            right = mid - 1
        else:
            return mid + 1
    # left == right + 1, so arr[right] < value < arr[left]
    return left

def binary_search_less_than(arr, value):
    left = 0
    right = len(arr) - 1
    if value < arr[left]:
        return None
    if value > arr[right]:
        return right
    while left <= right:
        mid = int((left + right) / 2)
        if value > arr[mid]:
            left = mid + 1
        elif value < arr[mid]:
            right = mid - 1
        else:
            return mid - 1
    # left == right + 1, so arr[right] < value < arr[left]
    return right

# count = 0
# if N == 1:
#     if A[0] < B[0] < C[0]:
#         count += 1
# else:
#     for bot in B:
#         index_A = binary_search_less_than(A, bot)
#         index_C = binary_search_more_than(C, bot)
#         # print(f"index_A: {index_A}")
#         # print(f"index_C: {index_C}")
#         if index_A != None and index_C != None:
#             count += (index_A + 1) * (N - index_C)

# print(count)

count = 0
for bot in B:
    i_A = bisect.bisect_left(A, bot)
    i_C = bisect.bisect_right(C, bot)
    count += i_A * (N - i_C)
print(count)