n=int(eval(input()))

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

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

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

ans=0

for i in b:

    he=-1

    ta=n

    while ta-he>1:

        mid=(he+ta)//2

        if i>a[mid]:

            he=mid

        else:

            ta=mid

    x=he+1



    he_=-1

    ta_=n

    while ta_-he_>1:

        mid_=(he_+ta_)//2

        if i>=c[mid_]:

            he_=mid_

        else:

            ta_=mid_

    y=n-ta_

    ans+=x*y

print(ans)
import bisect

n=int(eval(input()))

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

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

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

ans=0

for i in b:

    x=bisect.bisect_left(a,i)

    y=n-bisect.bisect_right(c,i)

    ans+=x*y

print(ans)
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
    he = -1
    ta = n
    while ta - he > 1:
        mid = (he + ta) // 2
        if i > a[mid]:
            he = mid
        else:
            ta = mid
    x = he + 1
    he_ = -1
    ta_ = n
    while ta_ - he_ > 1:
        mid_ = (he_ + ta_) // 2
        if i >= c[mid_]:
            he_ = mid_
        else:
            ta_ = mid_
    y = n - ta_
    ans += x * y
print(ans)

import bisect

n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
    x = bisect.bisect_left(a, i)
    y = n - bisect.bisect_right(c, i)
    ans += x * y
print(ans)

+import bisect + -    he = -1 -    ta = n -    while ta - he > 1: -        mid = (he + ta) // 2 -        if i > a[mid]: -            he = mid -        else: -            ta = mid -    x = he + 1 -    he_ = -1 -    ta_ = n -    while ta_ - he_ > 1: -        mid_ = (he_ + ta_) // 2 -        if i >= c[mid_]: -            he_ = mid_ -        else: -            ta_ = mid_ -    y = n - ta_ +    x = bisect.bisect_left(a, i) +    y = n - bisect.bisect_right(c, i)