### BUGGY CODE ###

N = int(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()

low = 0
high = len(A) -1

def check(mid, parts,key):
    if parts[mid] > key:
        return True
    return False
cnt = 0

for a in A:

    B_low = -1
    B_high = len(B) - 1
    b_cnt = 0
    if a >= B[B_high]:
        break
    while B_high -B_low > 1:
        mid = (B_high + B_low)//2

        if check(mid, B, a):
            B_high = mid
            # b_cnt = _cnt

        else:
            B_low = mid
    for b in B[B_high::]:
        C_high = len(C) - 1
        C_low = -1
        c_cnt = 0
        if b >= C[C_high]:
            break
        while C_high -C_low > 1:
            mid = (C_high + C_low) //2
            if check(mid,C ,b):
                C_high = mid
            else:
                C_low= mid
        # print(b, C_high, a)
        # print(len(C[C_high::]))
        cnt+=len(C[C_high::])

    # b_cnt = len(B) - B_high if B[B_high] > a  else 0
    # C_high = len(C) -1
    # C_low = -1
    # c_cnt = 0
    # if b_cnt >0:

    #     while C_high -C_low >1 :
    #         mid = (C_high + C_low )//2
    #         # _cnt = check(mid,C,B_high)
    #         if check(mid,C,B[B_high]):
    #             C_high  =mid
    #             # c_cnt = _cnt
    #         else:
    #             C_low = mid
    #     c_cnt = len(C) - C_high if C[C_high] > B[B_high] else 0
    # print(a,b_cnt,c_cnt)
    #
    # cnt += b_cnt * c_cnt
print(cnt)



### FIXED CODE ###

N = int(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()

low = 0
high = len(A) -1

def check(mid, parts,key):
    if parts[mid] > key:
        return True
    return False
cnt = 0

# for a in A:
#
#     B_low = -1
#     B_high = len(B) - 1
#     b_cnt = 0
#     if a >= B[B_high]:
#         break
#     while B_high -B_low > 1:
#         mid = (B_high + B_low)//2
#
#         if check(mid, B, a):
#             B_high = mid
#             # b_cnt = _cnt
#
#         else:
#             B_low = mid
#     for b in B[B_high::]:
#         C_high = len(C) - 1
#         C_low = -1
#         c_cnt = 0
#         if b >= C[C_high]:
#             break
#         while C_high -C_low > 1:
#             mid = (C_high + C_low) //2
#             if check(mid,C ,b):
#                 C_high = mid
#             else:
#                 C_low= mid
#         # print(b, C_high, a)
#         # print(len(C[C_high::]))
#         cnt+=len(C[C_high::])

    # b_cnt = len(B) - B_high if B[B_high] > a  else 0
    # C_high = len(C) -1
    # C_low = -1
    # c_cnt = 0
    # if b_cnt >0:

    #     while C_high -C_low >1 :
    #         mid = (C_high + C_low )//2
    #         # _cnt = check(mid,C,B_high)
    #         if check(mid,C,B[B_high]):
    #             C_high  =mid
    #             # c_cnt = _cnt
    #         else:
    #             C_low = mid
    #     c_cnt = len(C) - C_high if C[C_high] > B[B_high] else 0
    # print(a,b_cnt,c_cnt)
    #
    # cnt += b_cnt * c_cnt



for b in B:
    A_low = -1
    A_high = len(A)
    while A_high - A_low > 1:
        mid = (A_high + A_low) //2
        if A[mid] < b:
            A_low = mid
        else:
            A_high = mid

    a_cnt =  A_low + 1
    C_low = -1
    C_high = len(C)
    while C_high - C_low > 1:
        mid = (C_high + C_low) //2
        if C[mid] > b:
            C_high = mid
        else:
            C_low = mid
    c_cnt = len(C) - C_high

    cnt += a_cnt * c_cnt
print(cnt)