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 b_search_l(B,key):

    #key < B[s]を満たすsの個数

    if key < B[0]:

        return N

    elif key >= B[N-1]:

        return 0

    else:

        left,right = 0,N

        while left < right:

            mid = (left+right)//2

            if B[mid] <= key and key < B[mid+1]:

                return N-(mid+1)

            elif B[mid] > key:

                right = mid

            else:

                left = mid



def b_search_r(B,key):

    #key > B[t]を満たすtの個数

    if B[0] >= key:

        return 0

    elif B[N-1] < key:

        return N

    else:

        left,right = 0,N

        while left < right:

            mid = (left+right)//2

            if B[mid] < key and key <= B[mid+1]:

                return mid+1

            elif B[mid] >= key:

                right = mid

            else:

                left = mid



#b_l:keyより多い奴の個数

#b_r:key未満の奴の個数

ans = 0

for i in range(N):

    b_l,b_r = b_search_l(C,B[i]),b_search_r(A,B[i])

    ans += (b_l)*(b_r)

print(ans)

from bisect import bisect_left,bisect_right



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



#bisect_left:keyを挿入できる最小のindex

#bisect_right:keyを挿入できる最大のindex

ans = 0

for i in range(N):

    b_l,b_r = bisect_left(A,B[i]),N-bisect_right(C,B[i])

    ans += (b_l)*(b_r)

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 b_search_l(B, key):
    # key < B[s]を満たすsの個数
    if key < B[0]:
        return N
    elif key >= B[N - 1]:
        return 0
    else:
        left, right = 0, N
        while left < right:
            mid = (left + right) // 2
            if B[mid] <= key and key < B[mid + 1]:
                return N - (mid + 1)
            elif B[mid] > key:
                right = mid
            else:
                left = mid


def b_search_r(B, key):
    # key > B[t]を満たすtの個数
    if B[0] >= key:
        return 0
    elif B[N - 1] < key:
        return N
    else:
        left, right = 0, N
        while left < right:
            mid = (left + right) // 2
            if B[mid] < key and key <= B[mid + 1]:
                return mid + 1
            elif B[mid] >= key:
                right = mid
            else:
                left = mid


# b_l:keyより多い奴の個数
# b_r:key未満の奴の個数
ans = 0
for i in range(N):
    b_l, b_r = b_search_l(C, B[i]), b_search_r(A, B[i])
    ans += (b_l) * (b_r)
print(ans)

from bisect import bisect_left, bisect_right

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()
# bisect_left:keyを挿入できる最小のindex
# bisect_right:keyを挿入できる最大のindex
ans = 0
for i in range(N):
    b_l, b_r = bisect_left(A, B[i]), N - bisect_right(C, B[i])
    ans += (b_l) * (b_r)
print(ans)

+from bisect import bisect_left, bisect_right + - - -def b_search_l(B, key): -    # key < B[s]を満たすsの個数 -    if key < B[0]: -        return N -    elif key >= B[N - 1]: -        return 0 -    else: -        left, right = 0, N -        while left < right: -            mid = (left + right) // 2 -            if B[mid] <= key and key < B[mid + 1]: -                return N - (mid + 1) -            elif B[mid] > key: -                right = mid -            else: -                left = mid - - -def b_search_r(B, key): -    # key > B[t]を満たすtの個数 -    if B[0] >= key: -        return 0 -    elif B[N - 1] < key: -        return N -    else: -        left, right = 0, N -        while left < right: -            mid = (left + right) // 2 -            if B[mid] < key and key <= B[mid + 1]: -                return mid + 1 -            elif B[mid] >= key: -                right = mid -            else: -                left = mid - - -# b_l:keyより多い奴の個数 -# b_r:key未満の奴の個数 +# bisect_left:keyを挿入できる最小のindex +# bisect_right:keyを挿入できる最大のindex -    b_l, b_r = b_search_l(C, B[i]), b_search_r(A, B[i]) +    b_l, b_r = bisect_left(A, B[i]), N - bisect_right(C, B[i])