from sys import stdin





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



    nums = [0] * (N + 1)



    ng = -1

    for i, b in enumerate(B):

        ok = N

        while abs(ok - ng) > 1:

            mid = (ok + ng) // 2

            if C[mid] > b:

                ok = mid

            else:

                ng = mid



        nums[i] = N - ok



    for i in range(N, 0, -1):

        nums[i - 1] += nums[i]



    ans = 0

    ng = -1

    for a in A:

        ok = N

        while abs(ok - ng) > 1:

            mid = (ok + ng) // 2

            if B[mid] > a:

                ok = mid

            else:

                ng = mid



        ans += nums[ok]



    print(ans)





if __name__ == "__main__":

    main()

from sys import stdin

from bisect import 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()



    nums = [0] * (N + 1)



    pos = 0

    for i, b in enumerate(B):

        pos = bisect_left(C, b + 1, pos)

        nums[i] = N - pos



    for i in range(N, 0, -1):

        nums[i - 1] += nums[i]



    ans = 0

    pos = 0

    for a in A:

        pos = bisect_left(B, a + 1, pos)

        ans += nums[pos]



    print(ans)





if __name__ == "__main__":

    main()

from sys import stdin


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()
    nums = [0] * (N + 1)
    ng = -1
    for i, b in enumerate(B):
        ok = N
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if C[mid] > b:
                ok = mid
            else:
                ng = mid
        nums[i] = N - ok
    for i in range(N, 0, -1):
        nums[i - 1] += nums[i]
    ans = 0
    ng = -1
    for a in A:
        ok = N
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if B[mid] > a:
                ok = mid
            else:
                ng = mid
        ans += nums[ok]
    print(ans)


if __name__ == "__main__":
    main()

from sys import stdin
from bisect import 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()
    nums = [0] * (N + 1)
    pos = 0
    for i, b in enumerate(B):
        pos = bisect_left(C, b + 1, pos)
        nums[i] = N - pos
    for i in range(N, 0, -1):
        nums[i - 1] += nums[i]
    ans = 0
    pos = 0
    for a in A:
        pos = bisect_left(B, a + 1, pos)
        ans += nums[pos]
    print(ans)


if __name__ == "__main__":
    main()

+from bisect import bisect_left -    ng = -1 +    pos = 0 -        ok = N -        while abs(ok - ng) > 1: -            mid = (ok + ng) // 2 -            if C[mid] > b: -                ok = mid -            else: -                ng = mid -        nums[i] = N - ok +        pos = bisect_left(C, b + 1, pos) +        nums[i] = N - pos -    ng = -1 +    pos = 0 -        ok = N -        while abs(ok - ng) > 1: -            mid = (ok + ng) // 2 -            if B[mid] > a: -                ok = mid -            else: -                ng = mid -        ans += nums[ok] +        pos = bisect_left(B, a + 1, pos) +        ans += nums[pos]