N = int(eval(input()))

A = sorted(list(map(int, input().split())))

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

C = sorted(list(map(int, input().split())))



def BinaryIndexSearch_floor(p, SL):

	"""

	search the minimum number among the larger numbers than the ginven nymber "n". 

	return the index of it under the list sorted.

	"""

	#SL = sorted(L)

	l = 0

	r = len(SL) - 1



	while True:

		if l == r:

			if SL[l] > p:

				return l

			else:

				return -1

		elif r-l == 1:

			if SL[l] > p:

				return l

			elif SL[r] > p:

				return r

			else:

				return -1



		center = l + ((r-l) // 2)



		if SL[center] <= p:

			l = center + 1

			continue



		else:

			r = center

			continue



def BinaryIndexSearch_ceil(p, SL):

	#SL = sorted(L)

	l = 0

	r = len(SL) - 1



	while True:

		if l == r:

			if SL[l] < p:

				return l

			else:

				return -1

		elif r-l == 1:

			if SL[r] < p:

				return r

			elif SL[l] < p:

				return l

			else:

				return -1

		center = l + ((r-l) // 2)



		if SL[center] < p:

			l = center 

			continue



		else:

			r = center - 1

			continue



min_A = A[0]

max_C = C[-1]

ans = 0

for b in B:

	if not (min_A < b < max_C):

		continue



	a = BinaryIndexSearch_ceil(b,A)

	c = BinaryIndexSearch_floor(b,C)



	ans += (a+1) * (N-c)



print(ans)
import numpy as np

N = int(eval(input()))

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

A.sort()

A = np.array(A)

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

B.sort()

B = np.array(B)

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

C.sort()

C = np.array(C)



ans = 0

for i in range(N):

	b = B[i]

	a_ind = np.searchsorted(A,b,side='left')

	c_ind = np.searchsorted(C,b,side='right')

	ans += a_ind * (N-c_ind)



print(ans)
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))


def BinaryIndexSearch_floor(p, SL):
    """
    search the minimum number among the larger numbers than the ginven nymber "n".
    return the index of it under the list sorted.
    """
    # SL = sorted(L)
    l = 0
    r = len(SL) - 1
    while True:
        if l == r:
            if SL[l] > p:
                return l
            else:
                return -1
        elif r - l == 1:
            if SL[l] > p:
                return l
            elif SL[r] > p:
                return r
            else:
                return -1
        center = l + ((r - l) // 2)
        if SL[center] <= p:
            l = center + 1
            continue
        else:
            r = center
            continue


def BinaryIndexSearch_ceil(p, SL):
    # SL = sorted(L)
    l = 0
    r = len(SL) - 1
    while True:
        if l == r:
            if SL[l] < p:
                return l
            else:
                return -1
        elif r - l == 1:
            if SL[r] < p:
                return r
            elif SL[l] < p:
                return l
            else:
                return -1
        center = l + ((r - l) // 2)
        if SL[center] < p:
            l = center
            continue
        else:
            r = center - 1
            continue


min_A = A[0]
max_C = C[-1]
ans = 0
for b in B:
    if not (min_A < b < max_C):
        continue
    a = BinaryIndexSearch_ceil(b, A)
    c = BinaryIndexSearch_floor(b, C)
    ans += (a + 1) * (N - c)
print(ans)

import numpy as np

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)
ans = 0
for i in range(N):
    b = B[i]
    a_ind = np.searchsorted(A, b, side="left")
    c_ind = np.searchsorted(C, b, side="right")
    ans += a_ind * (N - c_ind)
print(ans)

+import numpy as np + -A = sorted(list(map(int, input().split()))) +A = list(map(int, input().split())) +A.sort() +A = np.array(A) -C = sorted(list(map(int, input().split()))) - - -def BinaryIndexSearch_floor(p, SL): -    """ -    search the minimum number among the larger numbers than the ginven nymber "n". -    return the index of it under the list sorted. -    """ -    # SL = sorted(L) -    l = 0 -    r = len(SL) - 1 -    while True: -        if l == r: -            if SL[l] > p: -                return l -            else: -                return -1 -        elif r - l == 1: -            if SL[l] > p: -                return l -            elif SL[r] > p: -                return r -            else: -                return -1 -        center = l + ((r - l) // 2) -        if SL[center] <= p: -            l = center + 1 -            continue -        else: -            r = center -            continue - - -def BinaryIndexSearch_ceil(p, SL): -    # SL = sorted(L) -    l = 0 -    r = len(SL) - 1 -    while True: -        if l == r: -            if SL[l] < p: -                return l -            else: -                return -1 -        elif r - l == 1: -            if SL[r] < p: -                return r -            elif SL[l] < p: -                return l -            else: -                return -1 -        center = l + ((r - l) // 2) -        if SL[center] < p: -            l = center -            continue -        else: -            r = center - 1 -            continue - - -min_A = A[0] -max_C = C[-1] +B.sort() +B = np.array(B) +C = list(map(int, input().split())) +C.sort() +C = np.array(C) -for b in B: -    if not (min_A < b < max_C): -        continue -    a = BinaryIndexSearch_ceil(b, A) -    c = BinaryIndexSearch_floor(b, C) -    ans += (a + 1) * (N - c) +for i in range(N): +    b = B[i] +    a_ind = np.searchsorted(A, b, side="left") +    c_ind = np.searchsorted(C, b, side="right") +    ans += a_ind * (N - c_ind)