def bs_left(list, target):

    low = 0

    high = len(list)



    while low < high:

        mid = (low + high) // 2

        if target > list[mid]:

            low = mid + 1

        else:

            high = mid

    return low



def bs_right(list, target):

    low = 0

    high = len(list)

    while low < high:

        mid = (low + high) // 2

        if target < list[mid]:

            high = mid

        else:

            low = mid + 1

    return low



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 b in B:

    ans += (bs_left(A, b) * (n - bs_right(C, b)))

print(ans)



import bisect



import sys

stdin=sys.stdin



ip=lambda: int(sp())

fp=lambda: float(sp())

lp=lambda:list(map(int,stdin.readline().split()))

sp=lambda:stdin.readline().rstrip()

yp=lambda:print('Yes')

np=lambda:print('No')



n=ip()

a=lp()

b=lp()

c=lp()



a.sort()

b.sort()

c.sort()

ans=0



for i in range(n):

  x=bisect.bisect_left(a,b[i])

  y=bisect.bisect_right(c,b[i])

  ans+=x*(n-y)

  

print(ans)





def bs_left(list, target):
    low = 0
    high = len(list)
    while low < high:
        mid = (low + high) // 2
        if target > list[mid]:
            low = mid + 1
        else:
            high = mid
    return low


def bs_right(list, target):
    low = 0
    high = len(list)
    while low < high:
        mid = (low + high) // 2
        if target < list[mid]:
            high = mid
        else:
            low = mid + 1
    return low


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 b in B:
    ans += bs_left(A, b) * (n - bs_right(C, b))
print(ans)

import bisect
import sys

stdin = sys.stdin
ip = lambda: int(sp())
fp = lambda: float(sp())
lp = lambda: list(map(int, stdin.readline().split()))
sp = lambda: stdin.readline().rstrip()
yp = lambda: print("Yes")
np = lambda: print("No")
n = ip()
a = lp()
b = lp()
c = lp()
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    x = bisect.bisect_left(a, b[i])
    y = bisect.bisect_right(c, b[i])
    ans += x * (n - y)
print(ans)

-def bs_left(list, target): -    low = 0 -    high = len(list) -    while low < high: -        mid = (low + high) // 2 -        if target > list[mid]: -            low = mid + 1 -        else: -            high = mid -    return low +import bisect +import sys - -def bs_right(list, target): -    low = 0 -    high = len(list) -    while low < high: -        mid = (low + high) // 2 -        if target < list[mid]: -            high = mid -        else: -            low = mid + 1 -    return low - - -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() +stdin = sys.stdin +ip = lambda: int(sp()) +fp = lambda: float(sp()) +lp = lambda: list(map(int, stdin.readline().split())) +sp = lambda: stdin.readline().rstrip() +yp = lambda: print("Yes") +np = lambda: print("No") +n = ip() +a = lp() +b = lp() +c = lp() +a.sort() +b.sort() +c.sort() -for b in B: -    ans += bs_left(A, b) * (n - bs_right(C, b)) +for i in range(n): +    x = bisect.bisect_left(a, b[i]) +    y = bisect.bisect_right(c, b[i]) +    ans += x * (n - y)