from bisect import bisect_right



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



b2c = [0] * (N+1)

for i in range(N):

    b = B[i]

    j = bisect_right(C, b)

    b2c[i] = N - j

    #print("B[%d]=%5d"%(i,b), "C[%d]=%5d"%(j, C[j]), "bc=%d"%(N-j))



for i in range(N-1)[::-1]:

    b2c[i] += b2c[i+1]

    pass

#print(b2c)



total = 0

for i in range(N):

    a = A[i]

    a2b = bisect_right(B, a)

    t = b2c[a2b]

    #print("%d:t=%d"%(i, t),a2b)

    total+=t



print(total)

    





def main():

    from bisect import bisect_right

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



    b2c = [0] * (N+1)

    for i in range(N):

        b = B[i]

        j = bisect_right(C, b)

        b2c[i] = N - j

        #print("B[%d]=%5d"%(i,b), "C[%d]=%5d"%(j, C[j]), "bc=%d"%(N-j))



    for i in range(N-1)[::-1]:

        b2c[i] += b2c[i+1]

        pass

    #print(b2c)



    total = 0

    for i in range(N):

        a = A[i]

        a2b = bisect_right(B, a)

        t = b2c[a2b]

        #print("%d:t=%d"%(i, t),a2b)

        total+=t



    print(total)

        

main()

from bisect import bisect_right

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())
b2c = [0] * (N + 1)
for i in range(N):
    b = B[i]
    j = bisect_right(C, b)
    b2c[i] = N - j
    # print("B[%d]=%5d"%(i,b), "C[%d]=%5d"%(j, C[j]), "bc=%d"%(N-j))
for i in range(N - 1)[::-1]:
    b2c[i] += b2c[i + 1]
    pass
# print(b2c)
total = 0
for i in range(N):
    a = A[i]
    a2b = bisect_right(B, a)
    t = b2c[a2b]
    # print("%d:t=%d"%(i, t),a2b)
    total += t
print(total)

def main():
    from bisect import bisect_right

    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())
    b2c = [0] * (N + 1)
    for i in range(N):
        b = B[i]
        j = bisect_right(C, b)
        b2c[i] = N - j
        # print("B[%d]=%5d"%(i,b), "C[%d]=%5d"%(j, C[j]), "bc=%d"%(N-j))
    for i in range(N - 1)[::-1]:
        b2c[i] += b2c[i + 1]
        pass
    # print(b2c)
    total = 0
    for i in range(N):
        a = A[i]
        a2b = bisect_right(B, a)
        t = b2c[a2b]
        # print("%d:t=%d"%(i, t),a2b)
        total += t
    print(total)


main()

-from bisect import bisect_right +def main(): +    from bisect import bisect_right -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()) -b2c = [0] * (N + 1) -for i in range(N): -    b = B[i] -    j = bisect_right(C, b) -    b2c[i] = N - j -    # print("B[%d]=%5d"%(i,b), "C[%d]=%5d"%(j, C[j]), "bc=%d"%(N-j)) -for i in range(N - 1)[::-1]: -    b2c[i] += b2c[i + 1] -    pass -# print(b2c) -total = 0 -for i in range(N): -    a = A[i] -    a2b = bisect_right(B, a) -    t = b2c[a2b] -    # print("%d:t=%d"%(i, t),a2b) -    total += t -print(total) +    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()) +    b2c = [0] * (N + 1) +    for i in range(N): +        b = B[i] +        j = bisect_right(C, b) +        b2c[i] = N - j +        # print("B[%d]=%5d"%(i,b), "C[%d]=%5d"%(j, C[j]), "bc=%d"%(N-j)) +    for i in range(N - 1)[::-1]: +        b2c[i] += b2c[i + 1] +        pass +    # print(b2c) +    total = 0 +    for i in range(N): +        a = A[i] +        a2b = bisect_right(B, a) +        t = b2c[a2b] +        # print("%d:t=%d"%(i, t),a2b) +        total += t +    print(total) + + +main()