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

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

    for b in B:

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



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


if __name__ == "__main__":
    main()

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