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

N = int(eval(input()))



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

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

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





def f(xn, yn, zn):

    tn = [0] * N

    num = 0

    j = N - 1



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

        while 0 <= j and xn[i] < yn[j]:

            num += zn[j]

            j -= 1

        tn[i] = num



    return tn





def main():

    Zn = [1] * N



    Zn = f(Bn, Cn, Zn)

    Zn = f(An, Bn, Zn)



    print((sum(Zn)))

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

N = int(eval(input()))
An = sorted(map(int, input().split()))
Bn = sorted(map(int, input().split()))
Cn = sorted(map(int, input().split()))


def f(xn, yn, zn):
    tn = [0] * N
    num = 0
    j = N - 1
    for i in range(N - 1, -1, -1):
        while 0 <= j and xn[i] < yn[j]:
            num += zn[j]
            j -= 1
        tn[i] = num
    return tn


def main():
    Zn = [1] * N
    Zn = f(Bn, Cn, Zn)
    Zn = f(An, Bn, Zn)
    print((sum(Zn)))
    return


main()

+N = int(eval(input())) +An = sorted(map(int, input().split())) +Bn = sorted(map(int, input().split())) +Cn = sorted(map(int, input().split())) + + +def f(xn, yn, zn): +    tn = [0] * N +    num = 0 +    j = N - 1 +    for i in range(N - 1, -1, -1): +        while 0 <= j and xn[i] < yn[j]: +            num += zn[j] +            j -= 1 +        tn[i] = num +    return tn + + -    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) +    Zn = [1] * N +    Zn = f(Bn, Cn, Zn) +    Zn = f(An, Bn, Zn) +    print((sum(Zn)))