CodeEff/ECCO huggingface dataset:
# Original solution
def m():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    cnt = 0
    for a in A:
        for b in B:
            for c in C:
                if a < b and b < c:
                    cnt +=1
    return cnt


print((m()))

# Optimized solution
def someone_ans():
    def binary_search(L, key, mode):
        low, high = 0, len(L)
        mid = len(L) // 2
        while low <= high - 1:
            if L[mid] < key and mode == 0 or L[mid] <= key and mode == 1:
                low = mid + 1
            else:
                high = mid
            mid = (low + high) // 2
        return high

    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    C.sort()
    ans = 0
    for i in B:
        Ai = binary_search(A, i, 0)
        Ci = len(C) - binary_search(C, i, 1)
        ans += Ai*Ci
    return ans


# print(m())
print((someone_ans()))
# Original solution
def solve():
    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_cand = [0 for i in range(N)]
    B_cand = [0 for i in range(N)]
    for i in range(N):
        cnt = 0
        for j in range(N):
            if B[i] < C[N-j-1]:
                cnt += 1
            else:
                break
        B_cand[i] = cnt
    
    for i in range(N):
        cnt = 0
        for j in range(N):
            if A[i] < B[N-j-1]:
                cnt += B_cand[N-j-1]
            else:
                break
        A_cand[i] = cnt
    print((sum(A_cand)))
    

solve()

# Optimized solution
def solve():
    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_cand = [0 for i in range(N)]
    B_cand = [0 for i in range(N)]
    
    skip_loop = 0
    for i in range(N):
        cnt = skip_loop
        for j in range(N-skip_loop):
            if B[N-i-1] < C[N-skip_loop-j-1]:
                cnt += 1
            else:
                break
        B_cand[N-i-1] = cnt
        skip_loop = cnt
    
    skip_loop = 0
    ans = 0
    pre_loop_ans = 0
    for i in range(N):
        cnt = skip_loop
        ans += pre_loop_ans
        for j in range(N-skip_loop):
            if A[N-i-1] < B[N-skip_loop-j-1]:
                ans += B_cand[N-skip_loop-j-1]
                pre_loop_ans += B_cand[N-skip_loop-j-1]
                cnt += 1
            else:
                break
        A_cand[N-i-1] = cnt
        skip_loop = cnt
    print(ans)
    

solve()
# Original solution
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for b in B:
    top = bisect.bisect_left(A, b)
    bottom = N - bisect.bisect_right(C, b)
    ans += top * bottom

print(ans)

# Optimized solution
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    top = bisect.bisect_left(A, B[i])
    bottom = N - bisect.bisect_right(C, B[i])
    ans += top * bottom

print(ans)
# Original solution
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    top = bisect.bisect_left(A, B[i])
    bottom = N - bisect.bisect_right(C, B[i])
    ans += top * bottom

print(ans)

# Optimized solution
import bisect

N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    top = bisect.bisect_left(A, B[i])
    bottom = N - bisect.bisect_right(C, B[i])
    ans += top * bottom

print(ans)
# Original solution
N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
sumSunuke = 0


def bs_left(list, target):
    low, high = 0, len(list)
    while low < high:
        mid = (low + high) // 2
        if list[mid] < target:
            low = mid + 1
        else:
            high = mid
    return low


def bs_right(list, target):
    low, high = 0, len(list)
    while low < high:
        mid = (low + high) // 2
        if list[mid] > target:
            high = mid
        else:
            low = mid + 1
    return low


for x in range(N):
    ab = bs_left(A, B[x])
    bc = N - bs_right(C, B[x])
    sumSunuke += ab * bc
print(sumSunuke)


# Optimized solution
from bisect import bisect_left, bisect_right

N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
sumSunuke = 0

for x in range(N):
    ab = bisect_left(A, B[x])
    bc = N - bisect_right(C, B[x])
    sumSunuke += ab * bc
print(sumSunuke)
# Original solution
import bisect
n = int(eval(input()))
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

cnt = 0
for b in bl:
    a_num = bisect.bisect_left(al,b)
    c_num = n - bisect.bisect_right(cl,b)
    cnt += a_num*c_num
    # cnt += c_num

print(cnt)

# Optimized solution
import bisect
n = int(eval(input()))
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

ans = 0
for b in bl:
    a_num = bisect.bisect_left(al,b)
    c_num = n - bisect.bisect_right(cl,b)
    ans += a_num*c_num

print(ans)
# Original solution
import bisect
n = int(eval(input()))
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

ans = 0
for b in bl:
    a_num = bisect.bisect_left(al,b)
    c_num = n - bisect.bisect_right(cl,b)
    ans += a_num*c_num

print(ans)

# Optimized solution
from bisect import bisect_left, bisect_right
n = int(eval(input()))
al = list(map(int,input().split()))
bl = list(map(int,input().split()))
cl = list(map(int,input().split()))

al.sort()
bl.sort()
cl.sort()

ans = 0
for b in bl:
    # b未満の要素の個数
    a_cnt = bisect_left(al,b)
    # bより大きい要素の個数
    c_cnt = n - bisect_right(cl,b)
    ans += a_cnt*c_cnt

print(ans)
# Original solution
import bisect

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

count = 0

for i in range(N):
    index_b = bisect.bisect_right(B, A[i])
    for j in range(index_b, N):
        index_c = bisect.bisect_right(C, B[j])
        count += N - index_c

print(count)

# Optimized solution
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

count = 0

for b in B:
    index_b = bisect.bisect_left(A, b)
    index_c = bisect.bisect_right(C, b)
    count += (N - index_c) * index_b

print(count)
# Original solution

n = int(eval(input()))
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(n - sum(x > a[i] for x in b), n):
        ans += sum(x > b[j] for x in c)

print(ans)

# Optimized solution
from bisect import bisect_left, bisect_right

n = int(eval(input()))
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))
ans = 0
def bin_search(x, n, flag):
    if flag == True:
        return bisect_left(x, n)
    else:
        return bisect_right(x, n)



for i in range(n):
    ans += bin_search(a, b[i], True) * (n - bin_search(c, b[i], False))

print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

adic = {}
bdic = {}
cdic = {}

for i in range(len(a)):
    if a[i] in adic:
        adic[a[i]] = adic[a[i]] + 1
    else:
        adic.update({a[i]:1})

for i in range(len(b)):
    if b[i] in bdic:
        bdic[b[i]] = bdic[b[i]] + 1
    else:
        bdic.update({b[i]:1})
for i in range(len(c)):
    if c[i] in cdic:
        cdic[c[i]] = cdic[c[i]] + 1
    else:
        cdic.update({c[i]:1})



        
        
summer = 0
for j in list(bdic.keys()):
    ai = 0
    ci = 0
    for i in list(adic.keys()):
        if i < j:
            ai = ai + adic[i]
    for k in list(cdic.keys()):
        if k > j:
            ci = ci + cdic[k]
    summer = summer + bdic[j] * ai * ci       
print(summer)
                
    
            

# Optimized solution
N = int(eval(input()))
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
c = list(map(int,input().split(" ")))
#アルゴリズムわからないけどN log N?
a.sort()
b.sort()
c.sort()
 
#O(N)?
i,j,k = 0,0,0
ans = 0
while j < N:
  while i < N and a[i]<b[j] :
    i += 1
  while k < N and c[k]<=b[j]:
    k += 1
  ans += i * (N - k)
  j += 1
 

print(ans)
# Original solution
import bisect

N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

ans = 0

for i in B:
    zyo = bisect.bisect_left(A, i)
    ge = bisect.bisect_right(C, i)
    ans += (N-ge)*zyo
    #print(ans, zyo, ge)
print(ans)

# Optimized solution
import bisect

N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

ans = 0

for i in B:
    ans += (bisect.bisect_left(A, i)) * (N-bisect.bisect_right(C, i))
print(ans)
# Original solution
import bisect

N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

ans = 0

for i in B:
    ans += (bisect.bisect_left(A, i)) * (N-bisect.bisect_right(C, i))
print(ans)

# Optimized solution
import bisect

N = int(eval(input()))
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0

for i in B:
    num_A = bisect.bisect_left(A, i)
    num_B = bisect.bisect_right(C, i)
    ans += num_A * (N - num_B)

print(ans)
# Original solution
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
asort = sorted(a)
bsort = sorted(b)
csort = sorted(c)
res = 0
for ai in a:
    bindex = bisect.bisect_right(bsort, ai)
    if bindex == n:
        continue
    for bi in bsort[bindex:]:
        cindex = bisect.bisect_right(csort, bi)
        if cindex == n:
            continue
        res += n-cindex
print(res)

# Optimized solution
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bsort = sorted(b)
csort = sorted(c)
res = 0
asum = [0] * n
bsum = [0] * n
for i in range(n):
    asum[i] = n - bisect.bisect_right(bsort, a[i])
for i in range(n):
    bsum[i] = n - bisect.bisect_right(csort, b[i])
bsum.sort()
total = 0
for i in range(n):
    total += bsum[i]
    bsum[i] = total
res = 0
for i in range(n):
    if asum[i] != 0:
        res += bsum[asum[i] -1]
print(res)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a=sorted(a)
b=sorted(b)
c=sorted(c)
c.reverse()

ans=0
max1=n-1

for x in range(n):
  maxC=c[x]
  min1=0
  while max1-min1>1:
    zantei=(max1+min1)//2
    if b[zantei]>=maxC:
      max1=zantei
    else:
      min1=zantei
  if b[max1]<maxC:
    ch=max1
  elif b[min1]>=maxC:
    continue
  else:
    
    ch=min1
  
  for y in range(ch+1):
    maxB=b[y]
    max2=n-1
    min2=0
    while max2-min2>1:
      zantei1=(max2+min2)//2
      if a[zantei1]>=maxB:
        max2=zantei1
      else:
        min2=zantei1
    if a[max2]<maxB:
      ch1=max2
    else:
      ch1=min2
      
    ans+=ch1+1
    
print(ans)
      

# Optimized solution
def bs_left(list, target):
    low = 0
    high = len(list)

    while low < high:
        mid = (low + high) // 2
        if target > list[mid]:
            low = mid + 1
        else:
            high = mid
    return low

def bs_right(list, target):
    low = 0
    high = len(list)
    while low < high:
        mid = (low + high) // 2
        if target < list[mid]:
            high = mid
        else:
            low = mid + 1
    return low

n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()

ans = 0
for b in B:
    ans += (bs_left(A, b) * (n - bs_right(C, b)))
print(ans)
# Original solution
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)

# Optimized solution
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)
# Original solution
import bisect
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()
cc = {}
for i in b:
    cc[i] = n-bisect.bisect_right(c, i)
sum = 0
for i in a:
    for j in [s for s in b if s > i]:
        sum += cc[j]
print(sum)


# Optimized solution
import bisect
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()
sum = 0
for i in b:
    sum += bisect.bisect_left(a, i)*(n-bisect.bisect_right(c, i))

print(sum)
# Original solution
n= int(eval(input()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))

lal = sorted(al,reverse = True)
lbl = sorted(bl,reverse = True)
lcl = sorted(cl,reverse = True)



d =[0]*n

for i in range(n):
    x = lbl[i]
    for j in range(n):
        y = lal[j]
        if x > y:
            d[i] = (n-j)
            break
        
res =0
for i in range(n):
    x = lcl[i]
    for j in range(n):
        y = lbl[j]
        if x >y:            
            res += sum(d[j:])
            break

print(res)

# Optimized solution
n= int(eval(input()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))

lal = sorted(al)
lbl = sorted(bl)
lcl = sorted(cl)


from bisect import bisect_left, bisect_right
 

res = 0

for i in range(n):
    bx = lbl[i]
    ax = bisect_left(lal,bx)
    cx = n - bisect_right(lcl,bx)
    
    res += ax*cx

print(res)
# Original solution
import bisect

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

ans = 0
for i in a:
  bi = bisect.bisect_right(b,i)
  for j in b[bi:]:
    ci = bisect.bisect_right(c,j)
    ans += (n-ci)
print(ans)

# Optimized solution
import bisect

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

ans = 0
for i in b:
  ai = bisect.bisect_left(a,i)
  ci = bisect.bisect_right(c,i)
  ans += ai*(n-ci)
print(ans)
# Original solution
import bisect

N = int(eval(input())) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

total = 0
for c in C:
    b_count = bisect.bisect_left(B, c) # bの数量
    for b in B[:b_count]:
        a_count = bisect.bisect_left(A, b) # aの数量
        total += a_count

print(total)


# Optimized solution
import bisect
import itertools

N = int(eval(input())) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

# Bの各要素でAを二分探索して返ってきたindexを先に保有しておく
b_counts = [0] * N
for i in range(N):
    b_count = bisect.bisect_left(A, B[i])
    b_counts[i] = b_count

cumsum_b_counts = list(itertools.accumulate(b_counts))
cumsum_b_counts = [0] + cumsum_b_counts

# Cの各要素でBを二分探索。上記で保有しておいたb_countsを活用する
total = 0
for c in C:
    count = bisect.bisect_left(B, c)
    total += cumsum_b_counts[count]

print(total)
# Original solution
#create date: 2020-08-06 09:16

import sys
stdin = sys.stdin
from bisect import bisect_left

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    c = na()
    a.sort()
    b.sort()
    c.sort()
    cnt = 0
    for ci in c:
        i = bisect_left(b, ci)
        if i == 0:
            continue
        for bi in b[:i]:
            j = bisect_left(a, bi)
            cnt += j
    print(cnt)

if __name__ == "__main__":
    main()

# Optimized solution
#create date: 2020-08-06 09:16

import sys
stdin = sys.stdin
from bisect import bisect_left, bisect_right

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    c = na()
    a.sort()
    b.sort()
    c.sort()
    cnt = 0
    #print(a, b, c)
    for bi in b:
        i = bisect_left(a, bi)
        j = bisect_right(c, bi)
        cnt += i * (n-j)
        #print(bi, i, n-j)
    print(cnt)

if __name__ == "__main__":
    main()
# Original solution
def isOK(array, index, key):
    if array[index] > key:
        return True
    else:
        return False

def binary_serch(array, key):
    ng = -1
    ok = len(array)

    while (abs(ok - ng) > 1):
        mid = (ok + ng)//2

        if isOK(array, mid, key):
            ok = mid
        else:
            ng = mid
    return ok
n = int(eval(input()))
array1 = list(map(int,input().split()))
array2 = list(map(int,input().split()))
array3 = list(map(int,input().split()))

# array1 = sorted(array1)
array2 = sorted(array2)
array3 = sorted(array3)

# a = binary_serch(array2, 5)
count=0
for array1_index in range(n):
    start_array2_index = binary_serch(array2, array1[array1_index])
    #print(array1[array1_index])
    for cor_array2_index in range(start_array2_index, n):
        #print(array2[cor_array2_index])
        start_array3_index = binary_serch(array3, array2[cor_array2_index])
        # for k in range(start_array3_index,n):
        #     print(array3)
        count+=abs(start_array3_index - n)
print(count)


# Optimized solution
def isOK_under(array, index, key):
    if array[index] >= key:
        return True
    else:
        return False

def isOK_over(array, index, key):
    if array[index] > key:
        return True
    else:
        return False

def binary_serch_under(array, key):
    ng = -1
    ok = len(array)

    while (abs(ok - ng) > 1):
        mid = (ok + ng)//2

        if isOK_under(array, mid, key):
            ok = mid
        else:
            ng = mid
    return ok

def binary_serch_over(array, key):
    ng = -1
    ok = len(array)
    while (abs(ok - ng) > 1):
        mid = (ok + ng)//2
        if isOK_over(array, mid, key):
            ok = mid
        else:
            ng = mid
    return ok

n = int(eval(input()))
array1 = list(map(int,input().split()))
array2 = list(map(int,input().split()))
array3 = list(map(int,input().split()))

array1 = sorted(array1)
array2 = sorted(array2)
array3 = sorted(array3)

# a = binary_serch(array2, 5)
count=0
# for array1_index in range(n):
#     start_array2_index = binary_serch(array2, array1[array1_index])
#     # print(array1[array1_index])
#     for cor_array2_index in range(start_array2_index, n):
#         # print(array2[cor_array2_index])
#         start_array3_index = binary_serch(array3, array2[cor_array2_index])
#         # for k in range(start_array3_index,n):
#         #     print(array3)
#         count+=abs(start_array3_index - n)
for index_array2 in range(n):
    a = binary_serch_under(array1, array2[index_array2])
    c = binary_serch_over(array3, array2[index_array2])
    count += a*abs(c-n)
print(count)
# Original solution
n=int(eval(input()))
a,b,c=[list(map(int,input().split())) for _ in [0]*3]
from itertools import accumulate
a.sort()
b.sort()
c.sort()
a+=[10**20]
b+=[10**20]

p,q=0,0
cnt=0
ans=[0]*n
for i in range(n):
	for j in range(p,n+1):
		if b[i]>a[j]:
			pass
		else:
			break
	ans[i]=j
	p=j
ans=[0]+list(accumulate(ans))

for i in range(n):
	for j in range(q,n+1):
		if c[i]>b[j]:
			pass
		else:
			break
	cnt+=ans[j]
print(cnt)

# Optimized solution
n=int(eval(input()))
a,b,c=[list(map(int,input().split())) for _ in [0]*3]
from itertools import accumulate
a.sort()
b.sort()
c.sort()
a+=[10**20]
b+=[10**20]
 
p,q=0,0
cnt=0
ans=[0]*n
for i in range(n):
    for j in range(p,n+1):
        if b[i]>a[j]:
            pass
        else:
            break
    ans[i]=j
    p=j
ans=[0]+list(accumulate(ans))

for i in range(n):
    for j in range(q,n+1):
        if c[i]>b[j]:
            pass
        else:
            break
    q=j
    cnt+=ans[j]
print(cnt)
# Original solution
from bisect import bisect_left

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

# print(A)
# print(B)
# print(C)

A_B = []

for i in range(n):
    A_B.append(bisect_left(A, B[i]))

ruisekiwa = [A_B[0]]
for i in range(1, n):
    ruisekiwa.append(ruisekiwa[-1] + A_B[i])

# print(A_B)
# print(ruisekiwa)

ans = 0

for i in range(n):
    idx = bisect_left(B, C[i])
    if idx:
        ans += ruisekiwa[idx-1]

print(ans)

# Optimized solution
from bisect import bisect_left, bisect_right

n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

ans = 0

for i in range(n):
    ans += bisect_left(A, B[i]) * (n - bisect_right(C, B[i]))

print(ans)
# Original solution
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()

BClist = []
for i in range(N):
    for j in range(N):
        if(B[i] < C[j]):
            BClist.append(N-j)
            break

ans = 0
for k in range(N):
    for i in range(N):
        if(A[k] < B[i]):
            ans += sum(BClist[i:])
            break

print(ans)

# Optimized solution
import bisect

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
a.sort()
b.sort()
c.sort()

for j in range(n):
    ans += bisect.bisect_left(a,b[j])*(n-bisect.bisect_right(c,b[j]))
print(ans)
# Original solution
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())))

cnt = 0
for j in range(N):
  target = B[j]
  insert_indexA = bisect.bisect_left(A, target)
  insert_indexC = bisect.bisect_right(C, target)
  cnt = cnt + len(A[:insert_indexA]) * len(C[insert_indexC:])

print(cnt)

# Optimized solution
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())))

cnt = 0
for j in range(N):
  target = B[j]
  insert_indexA = bisect.bisect_left(A, target)
  insert_indexC = bisect.bisect_right(C, target)
  cnt = cnt + insert_indexA * (len(C)-insert_indexC)

print(cnt)