from sys import stdin

from bisect import bisect_right, bisect_left





def input():

    return stdin.readline().strip()





def main():

    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

    i, j = 0, 0

    for b in B:

        i = bisect_left(A, b, lo=i)

        j = bisect_right(C, b, lo=j)

        ans += i * (N - j)



    print(ans)





if __name__ == "__main__":

    main()

from sys import stdin

from bisect import bisect_right, bisect_left





def input():

    return stdin.readline().strip()





def main():

    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 = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)

    print(ans)





if __name__ == "__main__":

    main()

from sys import stdin
from bisect import bisect_right, bisect_left


def input():
    return stdin.readline().strip()


def main():
    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
    i, j = 0, 0
    for b in B:
        i = bisect_left(A, b, lo=i)
        j = bisect_right(C, b, lo=j)
        ans += i * (N - j)
    print(ans)


if __name__ == "__main__":
    main()

from sys import stdin
from bisect import bisect_right, bisect_left


def input():
    return stdin.readline().strip()


def main():
    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 = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)
    print(ans)


if __name__ == "__main__":
    main()

-    ans = 0 -    i, j = 0, 0 -    for b in B: -        i = bisect_left(A, b, lo=i) -        j = bisect_right(C, b, lo=j) -        ans += i * (N - j) +    ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)