def main():

    N = int(eval(input()))



    A = sorted(map(int, input().split()))

    B = sorted(map(int, input().split()))

    C = sorted(map(int, input().split()))



    def lowerBound(a, v):

        # 以上

        return lb(a, 0, len(a), v)



    def upperBound(a, v):

        # より大きい

        # 値をプラス1

        return lb(a, 0, len(a), v + 1)



    def lb(a, l, r, v):

        low = l - 1

        high = r



        while high - low > 1:

            mid = low + high >> 1

            if a[mid] >= v:

                high = mid

            else:

                low = mid



        return high



    print((sum([lowerBound(A, Bi) * (N - upperBound(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 = sorted(map(int, input().split()))

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

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



    ans = 0

    lx = 0

    ux = 0



    for Bi in Bn:

        # 以上

        lx = bisect_left(An, Bi, lx, N)



        # より大きい

        ux = bisect_right(Cn, Bi, ux, N)



        ans += lx * (N - ux)



    print(ans)

    return





main()

def main():
    N = int(eval(input()))
    A = sorted(map(int, input().split()))
    B = sorted(map(int, input().split()))
    C = sorted(map(int, input().split()))

    def lowerBound(a, v):
        # 以上
        return lb(a, 0, len(a), v)

    def upperBound(a, v):
        # より大きい
        # 値をプラス1
        return lb(a, 0, len(a), v + 1)

    def lb(a, l, r, v):
        low = l - 1
        high = r
        while high - low > 1:
            mid = low + high >> 1
            if a[mid] >= v:
                high = mid
            else:
                low = mid
        return high

    print((sum([lowerBound(A, Bi) * (N - upperBound(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 = sorted(map(int, input().split()))
    Bn = sorted(map(int, input().split()))
    Cn = sorted(map(int, input().split()))
    ans = 0
    lx = 0
    ux = 0
    for Bi in Bn:
        # 以上
        lx = bisect_left(An, Bi, lx, N)
        # より大きい
        ux = bisect_right(Cn, Bi, ux, N)
        ans += lx * (N - ux)
    print(ans)
    return


main()

+    from bisect import bisect_left +    from bisect import bisect_right + -    A = sorted(map(int, input().split())) -    B = sorted(map(int, input().split())) -    C = sorted(map(int, input().split())) - -    def lowerBound(a, v): +    An = sorted(map(int, input().split())) +    Bn = sorted(map(int, input().split())) +    Cn = sorted(map(int, input().split())) +    ans = 0 +    lx = 0 +    ux = 0 +    for Bi in Bn: -        return lb(a, 0, len(a), v) - -    def upperBound(a, v): +        lx = bisect_left(An, Bi, lx, N) -        # 値をプラス1 -        return lb(a, 0, len(a), v + 1) - -    def lb(a, l, r, v): -        low = l - 1 -        high = r -        while high - low > 1: -            mid = low + high >> 1 -            if a[mid] >= v: -                high = mid -            else: -                low = mid -        return high - -    print((sum([lowerBound(A, Bi) * (N - upperBound(C, Bi)) for Bi in B]))) +        ux = bisect_right(Cn, Bi, ux, N) +        ans += lx * (N - ux) +    print(ans)