import bisect

n=int(eval(input()))

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

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

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

countb=[]

count1=0

for i in range(n):

  index=bisect.bisect_left(la,lb[i])

  countb.append(index)

countb2=[]

sum=0

for i in range(n):

  sum+=countb[i]

  countb2.append(sum)

ans=0

for i in range(n):

  index=bisect.bisect_left(lb,lc[i])

  if index==0:

    pass

  else:

    ans+=countb2[index-1]

print(ans)
import bisect

n=int(eval(input()))

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

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

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

ans=0

for i in range(n):

  index1=bisect.bisect_left(la,lb[i])

  index2=bisect.bisect_right(lc,lb[i])

  ans+=index1*(n-index2)

print(ans)
import bisect

n = int(eval(input()))
la = sorted(map(int, input().split()))
lb = sorted(map(int, input().split()))
lc = sorted(map(int, input().split()))
countb = []
count1 = 0
for i in range(n):
    index = bisect.bisect_left(la, lb[i])
    countb.append(index)
countb2 = []
sum = 0
for i in range(n):
    sum += countb[i]
    countb2.append(sum)
ans = 0
for i in range(n):
    index = bisect.bisect_left(lb, lc[i])
    if index == 0:
        pass
    else:
        ans += countb2[index - 1]
print(ans)

import bisect

n = int(eval(input()))
la = sorted(map(int, input().split()))
lb = sorted(map(int, input().split()))
lc = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    index1 = bisect.bisect_left(la, lb[i])
    index2 = bisect.bisect_right(lc, lb[i])
    ans += index1 * (n - index2)
print(ans)

-countb = [] -count1 = 0 -for i in range(n): -    index = bisect.bisect_left(la, lb[i]) -    countb.append(index) -countb2 = [] -sum = 0 -for i in range(n): -    sum += countb[i] -    countb2.append(sum) -    index = bisect.bisect_left(lb, lc[i]) -    if index == 0: -        pass -    else: -        ans += countb2[index - 1] +    index1 = bisect.bisect_left(la, lb[i]) +    index2 = bisect.bisect_right(lc, lb[i]) +    ans += index1 * (n - index2)