def main():

    from bisect import bisect_left

    from bisect import bisect_right



    N = int(eval(input()))



    An = list(map(int, input().split()))

    Bn = list(map(int, input().split()))

    Cn = list(map(int, input().split()))



    A = sorted(An)

    C = sorted(Cn)



    print((sum(bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in Bn)))

    return





main()

def main():

    from bisect import bisect_left

    from bisect import bisect_right



    N = int(eval(input()))



    An = list(map(int, input().split()))

    Bn = list(map(int, input().split()))

    Cn = list(map(int, input().split()))



    A = sorted(An)

    B = sorted(Bn)

    C = sorted(Cn)



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

    return





main()

def main():
    from bisect import bisect_left
    from bisect import bisect_right

    N = int(eval(input()))
    An = list(map(int, input().split()))
    Bn = list(map(int, input().split()))
    Cn = list(map(int, input().split()))
    A = sorted(An)
    C = sorted(Cn)
    print((sum(bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in Bn)))
    return


main()

def main():
    from bisect import bisect_left
    from bisect import bisect_right

    N = int(eval(input()))
    An = list(map(int, input().split()))
    Bn = list(map(int, input().split()))
    Cn = list(map(int, input().split()))
    A = sorted(An)
    B = sorted(Bn)
    C = sorted(Cn)
    print((sum([bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in B])))
    return


main()

+    B = sorted(Bn) -    print((sum(bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in Bn))) +    print((sum([bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in B])))