from bisect import bisect_right

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



def main():

    N = int(readline())

    A = [int(i) for i in readline().split()]

    B = [int(i) for i in readline().split()]

    C = [int(i) for i in readline().split()]



    A.sort()

    B.sort()

    C.sort()



    a_ind = []

    b_ind = []

    for i in range(N):

        a_ind.append(bisect_right(B, A[i]))

        b_ind.append(N - bisect_right(C, B[i]))





    b_acc = [0]

    for b in b_ind:

        b_acc.append(b_acc[-1] + b)





    sum_b = b_acc[-1]

    ans = 0

    for i in a_ind:

        ans += sum_b - b_acc[i]



    print(ans)





if __name__ == "__main__":

    main()

from bisect import bisect_right, bisect_left

import sys

read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines



def main():

    N = int(readline())

    A = [int(i) for i in readline().split()]

    B = [int(i) for i in readline().split()]

    C = [int(i) for i in readline().split()]



    A.sort()

    B.sort()

    C.sort()



    ans = 0

    for b in B:

        ans += bisect_left(A, b) * (N - bisect_right(C, b))



    print(ans)





if __name__ == "__main__":

    main()

from bisect import bisect_right
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]
    C = [int(i) for i in readline().split()]
    A.sort()
    B.sort()
    C.sort()
    a_ind = []
    b_ind = []
    for i in range(N):
        a_ind.append(bisect_right(B, A[i]))
        b_ind.append(N - bisect_right(C, B[i]))
    b_acc = [0]
    for b in b_ind:
        b_acc.append(b_acc[-1] + b)
    sum_b = b_acc[-1]
    ans = 0
    for i in a_ind:
        ans += sum_b - b_acc[i]
    print(ans)


if __name__ == "__main__":
    main()

from bisect import bisect_right, bisect_left
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]
    C = [int(i) for i in readline().split()]
    A.sort()
    B.sort()
    C.sort()
    ans = 0
    for b in B:
        ans += bisect_left(A, b) * (N - bisect_right(C, b))
    print(ans)


if __name__ == "__main__":
    main()

-from bisect import bisect_right +from bisect import bisect_right, bisect_left -    a_ind = [] -    b_ind = [] -    for i in range(N): -        a_ind.append(bisect_right(B, A[i])) -        b_ind.append(N - bisect_right(C, B[i])) -    b_acc = [0] -    for b in b_ind: -        b_acc.append(b_acc[-1] + b) -    sum_b = b_acc[-1] -    for i in a_ind: -        ans += sum_b - b_acc[i] +    for b in B: +        ans += bisect_left(A, b) * (N - bisect_right(C, b))