def main():

    import numpy as np

    n=int(eval(input()))

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

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

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

    a.sort()

    b.sort()

    c.sort()

    a=np.array(a)

    b=np.array(b)

    c=np.array(c)



    cnt_a=np.searchsorted(b,a).tolist()

    cnt_b=np.searchsorted(c,b).tolist()



    ans,j=0,0

    for i in range(n):

        ans+=sum(cnt_b[j:cnt_a[i]])*(n-i)

        j=cnt_a[i]

    print(ans)

if __name__=='__main__':

    main()
def main():

    import numpy as np

    n=int(eval(input()))

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

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

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

    a.sort()

    b.sort()

    c.sort()

    a=np.array(a)

    b=np.array(b)

    c=np.array(c)



    cnt_a=np.searchsorted(a,b)

    cnt_c=n-np.searchsorted(c,b,side='right')

    print((np.sum(cnt_a*cnt_c)))

if __name__=='__main__':

    main()
def main():
    import numpy as np

    n = int(eval(input()))
    c = list(map(int, input().split()))
    b = list(map(int, input().split()))
    a = list(map(int, input().split()))
    a.sort()
    b.sort()
    c.sort()
    a = np.array(a)
    b = np.array(b)
    c = np.array(c)
    cnt_a = np.searchsorted(b, a).tolist()
    cnt_b = np.searchsorted(c, b).tolist()
    ans, j = 0, 0
    for i in range(n):
        ans += sum(cnt_b[j : cnt_a[i]]) * (n - i)
        j = cnt_a[i]
    print(ans)


if __name__ == "__main__":
    main()

def main():
    import numpy as np

    n = int(eval(input()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    a.sort()
    b.sort()
    c.sort()
    a = np.array(a)
    b = np.array(b)
    c = np.array(c)
    cnt_a = np.searchsorted(a, b)
    cnt_c = n - np.searchsorted(c, b, side="right")
    print((np.sum(cnt_a * cnt_c)))


if __name__ == "__main__":
    main()

+    a = list(map(int, input().split())) +    b = list(map(int, input().split())) -    b = list(map(int, input().split())) -    a = list(map(int, input().split())) -    cnt_a = np.searchsorted(b, a).tolist() -    cnt_b = np.searchsorted(c, b).tolist() -    ans, j = 0, 0 -    for i in range(n): -        ans += sum(cnt_b[j : cnt_a[i]]) * (n - i) -        j = cnt_a[i] -    print(ans) +    cnt_a = np.searchsorted(a, b) +    cnt_c = n - np.searchsorted(c, b, side="right") +    print((np.sum(cnt_a * cnt_c)))