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()



def n_smaller_a(num):

    if num>a[n-1]:

        return n

    if num<=a[0]:

        return 0

    left=0

    right=n-1

    mid=(left+right)//2

    while right-left>1:

        if a[mid]>=num:

            right=mid

        else:

            left=mid

        mid=(left+right)//2



    if a[left]==num:

        return left

    else:

        return left+1



def n_bigger_c(num):

    if num >= c[n-1]:

        return 0

    if num < c[0]:

        return n

    left=0

    right=n-1

    mid=(left+right)//2

    while right-left>1:

        if c[mid]>num:

            right=mid

        else:

            left=mid

        mid=(left+right)//2

    if c[right]==num:

        return n-right-1

    else:

        return n-right



ans = 0



for i in range(n):

    ans+=n_bigger_c(b[i])*n_smaller_a(b[i])

print(ans)

import bisect

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(n):

    ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))

print(ans)

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()


def n_smaller_a(num):
    if num > a[n - 1]:
        return n
    if num <= a[0]:
        return 0
    left = 0
    right = n - 1
    mid = (left + right) // 2
    while right - left > 1:
        if a[mid] >= num:
            right = mid
        else:
            left = mid
        mid = (left + right) // 2
    if a[left] == num:
        return left
    else:
        return left + 1


def n_bigger_c(num):
    if num >= c[n - 1]:
        return 0
    if num < c[0]:
        return n
    left = 0
    right = n - 1
    mid = (left + right) // 2
    while right - left > 1:
        if c[mid] > num:
            right = mid
        else:
            left = mid
        mid = (left + right) // 2
    if c[right] == num:
        return n - right - 1
    else:
        return n - right


ans = 0
for i in range(n):
    ans += n_bigger_c(b[i]) * n_smaller_a(b[i])
print(ans)

import bisect

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(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)

+import bisect + - - -def n_smaller_a(num): -    if num > a[n - 1]: -        return n -    if num <= a[0]: -        return 0 -    left = 0 -    right = n - 1 -    mid = (left + right) // 2 -    while right - left > 1: -        if a[mid] >= num: -            right = mid -        else: -            left = mid -        mid = (left + right) // 2 -    if a[left] == num: -        return left -    else: -        return left + 1 - - -def n_bigger_c(num): -    if num >= c[n - 1]: -        return 0 -    if num < c[0]: -        return n -    left = 0 -    right = n - 1 -    mid = (left + right) // 2 -    while right - left > 1: -        if c[mid] > num: -            right = mid -        else: -            left = mid -        mid = (left + right) // 2 -    if c[right] == num: -        return n - right - 1 -    else: -        return n - right - - -    ans += n_bigger_c(b[i]) * n_smaller_a(b[i]) +    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))