#!/usr/bin/env python3

def main():

    from bisect import bisect



    N = int(eval(input()))

    A = sorted([int(x) for x in input().split()])

    B = sorted([int(x) for x in input().split()])

    C = sorted([int(x) for x in input().split()])



    lst = [N - bisect(C, b) for b in B]

    lst = lst[::-1]

    tmp_lst = [lst[0]]

    for i in lst[1:]:

        tmp_lst.append(i + tmp_lst[-1])

    tmp_lst = tmp_lst[::-1]



    ans = 0

    for a in A:

        res = bisect(B, a)

        ans += tmp_lst[res] if res < N else 0

    print(ans)





if __name__ == '__main__':

    main()

#!/usr/bin/env python3

def main():

    from bisect import bisect, bisect_left



    N = int(eval(input()))

    A = sorted([int(x) for x in input().split()])

    B = sorted([int(x) for x in input().split()])

    C = sorted([int(x) for x in input().split()])



    print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))





if __name__ == '__main__':

    main()

#!/usr/bin/env python3
def main():
    from bisect import bisect

    N = int(eval(input()))
    A = sorted([int(x) for x in input().split()])
    B = sorted([int(x) for x in input().split()])
    C = sorted([int(x) for x in input().split()])
    lst = [N - bisect(C, b) for b in B]
    lst = lst[::-1]
    tmp_lst = [lst[0]]
    for i in lst[1:]:
        tmp_lst.append(i + tmp_lst[-1])
    tmp_lst = tmp_lst[::-1]
    ans = 0
    for a in A:
        res = bisect(B, a)
        ans += tmp_lst[res] if res < N else 0
    print(ans)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
def main():
    from bisect import bisect, bisect_left

    N = int(eval(input()))
    A = sorted([int(x) for x in input().split()])
    B = sorted([int(x) for x in input().split()])
    C = sorted([int(x) for x in input().split()])
    print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))


if __name__ == "__main__":
    main()

-    from bisect import bisect +    from bisect import bisect, bisect_left -    lst = [N - bisect(C, b) for b in B] -    lst = lst[::-1] -    tmp_lst = [lst[0]] -    for i in lst[1:]: -        tmp_lst.append(i + tmp_lst[-1]) -    tmp_lst = tmp_lst[::-1] -    ans = 0 -    for a in A: -        res = bisect(B, a) -        ans += tmp_lst[res] if res < N else 0 -    print(ans) +    print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))