def is_ok_under(array, mid, target):

    return array[mid] < target





def is_ok_over(array, mid, target):

    return array[mid] > target





# ok is -1. ng is len(array)

def bSearchUnder(array, ok, ng, target):

    while (abs(ok - ng) > 1):

        mid = (ok + ng) // 2

        if is_ok_under(array, mid, target):

            ok = mid

        else:

            ng = mid

    return ok





# ng is -1. ok is len(array)

def bSearchOver(array, ok, ng, target):

    while (abs(ok - ng) > 1):

        mid = (ok + ng) // 2

        if is_ok_over(array, mid, target):

            ok = mid

        else:

            ng = mid

    return ok





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 i in range(len(b)):

    add = 1

    add *= bSearchUnder(a, -1, len(a), b[i]) + 1

    add *= len(c) - bSearchOver(c, len(c), -1, b[i])

    ans += add



print(ans)

def binSearch(array, num):

    n = len(array)

    l = -1

    r = n



    while l + 1 < r:

        m = (l + r) // 2

        if num <= array[m]:

            r = m

        else:

            l = m



    return r





n = int(eval(input()))



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

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

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



a.sort()

c.sort()



ans = 0

for i in range(len(b)):

    a_idx = binSearch(a, b[i])

    c_idx = binSearch(c, b[i] + 1)

    ans += a_idx * (n - c_idx)

print(ans)

def is_ok_under(array, mid, target):
    return array[mid] < target


def is_ok_over(array, mid, target):
    return array[mid] > target


# ok is -1. ng is len(array)
def bSearchUnder(array, ok, ng, target):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok_under(array, mid, target):
            ok = mid
        else:
            ng = mid
    return ok


# ng is -1. ok is len(array)
def bSearchOver(array, ok, ng, target):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok_over(array, mid, target):
            ok = mid
        else:
            ng = mid
    return ok


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 i in range(len(b)):
    add = 1
    add *= bSearchUnder(a, -1, len(a), b[i]) + 1
    add *= len(c) - bSearchOver(c, len(c), -1, b[i])
    ans += add
print(ans)

def binSearch(array, num):
    n = len(array)
    l = -1
    r = n
    while l + 1 < r:
        m = (l + r) // 2
        if num <= array[m]:
            r = m
        else:
            l = m
    return r


n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in range(len(b)):
    a_idx = binSearch(a, b[i])
    c_idx = binSearch(c, b[i] + 1)
    ans += a_idx * (n - c_idx)
print(ans)

-def is_ok_under(array, mid, target): -    return array[mid] < target - - -def is_ok_over(array, mid, target): -    return array[mid] > target - - -# ok is -1. ng is len(array) -def bSearchUnder(array, ok, ng, target): -    while abs(ok - ng) > 1: -        mid = (ok + ng) // 2 -        if is_ok_under(array, mid, target): -            ok = mid +def binSearch(array, num): +    n = len(array) +    l = -1 +    r = n +    while l + 1 < r: +        m = (l + r) // 2 +        if num <= array[m]: +            r = m -            ng = mid -    return ok - - -# ng is -1. ok is len(array) -def bSearchOver(array, ok, ng, target): -    while abs(ok - ng) > 1: -        mid = (ok + ng) // 2 -        if is_ok_over(array, mid, target): -            ok = mid -        else: -            ng = mid -    return ok +            l = m +    return r -b.sort() -    add = 1 -    add *= bSearchUnder(a, -1, len(a), b[i]) + 1 -    add *= len(c) - bSearchOver(c, len(c), -1, b[i]) -    ans += add +    a_idx = binSearch(a, b[i]) +    c_idx = binSearch(c, b[i] + 1) +    ans += a_idx * (n - c_idx)