def biserch(l,key,flag=True):

    if flag is True:

        func = judge_1

    else:

        func = judge_2

    left = -1; right = len(l)

    while right - left > 1:

        middle = (left+right) // 2

        if func(l,key,middle) is True:

            right = middle

        else:

            left = middle

    return right



def judge_1(l,key,middle):

    if key <= l[middle]:

        return True

    else:

        return False



def judge_2(l,key,middle):

    if key < l[middle]:

        return True

    else:

        return False



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:

    top = biserch(A,b)

    bottom = N - biserch(C,b,flag=False)

    ans += top*bottom

print(ans)
def biserch_min(l,key):

    left = 0; right = len(l)

    while left < right:

        mid = (left+right)//2

        if l[mid] < key:

            left = mid+1

        else:

            right = mid

    return left



def biserch_max(l,key):

    left = 0; right = len(l)

    while left < right:

        mid = (left+right)//2

        if key < l[mid]:

            right = mid

        else:

            left = mid+1

    return right





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:

    top = biserch_min(A,b)

    bottom = N - biserch_max(C,b)

    ans += top*bottom

print(ans)
def biserch(l, key, flag=True):
    if flag is True:
        func = judge_1
    else:
        func = judge_2
    left = -1
    right = len(l)
    while right - left > 1:
        middle = (left + right) // 2
        if func(l, key, middle) is True:
            right = middle
        else:
            left = middle
    return right


def judge_1(l, key, middle):
    if key <= l[middle]:
        return True
    else:
        return False


def judge_2(l, key, middle):
    if key < l[middle]:
        return True
    else:
        return False


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:
    top = biserch(A, b)
    bottom = N - biserch(C, b, flag=False)
    ans += top * bottom
print(ans)

def biserch_min(l, key):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if l[mid] < key:
            left = mid + 1
        else:
            right = mid
    return left


def biserch_max(l, key):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if key < l[mid]:
            right = mid
        else:
            left = mid + 1
    return right


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:
    top = biserch_min(A, b)
    bottom = N - biserch_max(C, b)
    ans += top * bottom
print(ans)

-def biserch(l, key, flag=True): -    if flag is True: -        func = judge_1 -    else: -        func = judge_2 -    left = -1 +def biserch_min(l, key): +    left = 0 -    while right - left > 1: -        middle = (left + right) // 2 -        if func(l, key, middle) is True: -            right = middle +    while left < right: +        mid = (left + right) // 2 +        if l[mid] < key: +            left = mid + 1 -            left = middle -    return right +            right = mid +    return left -def judge_1(l, key, middle): -    if key <= l[middle]: -        return True -    else: -        return False - - -def judge_2(l, key, middle): -    if key < l[middle]: -        return True -    else: -        return False +def biserch_max(l, key): +    left = 0 +    right = len(l) +    while left < right: +        mid = (left + right) // 2 +        if key < l[mid]: +            right = mid +        else: +            left = mid + 1 +    return right -    top = biserch(A, b) -    bottom = N - biserch(C, b, flag=False) +    top = biserch_min(A, b) +    bottom = N - biserch_max(C, b)