icase=0

if icase==0:

    n=int(eval(input()))  #数値入力 「N」だけの入力のとき

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

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

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

elif icase==1:

    n=2

    a=[1,5]

    b=[2,4]

    c=[3,6]

elif icase==2:

    n=6

    a=[3, 14, 159, 2, 6, 53]

    b=[58, 9, 79, 323, 84, 6]

    c=[2643, 383, 2, 79, 50, 288]

    

a.sort()

b.sort()

c.sort()

   

icnt=0

ast=0

cst=0

for i in range(n):

    if a[n-1]<=b[i]:

        ast=n

#        print("a1:",ast-1,a[ast-1],i,b[i])

    elif a[0]>=b[i]:

        ast=0

#        print("a1:",ast-1,a[ast-1],i,b[i])

    else:

        while a[ast]<b[i] and ast<n-1:

            ast=ast+1

#            print("a2:",ast-1,a[ast-1],i,b[i])

    if b[i]<c[0]:

        cst=0 

    elif b[i]>=c[n-1]:

        cst=n 

#        print("c1:",cst,c[cst],i,b[i])

    else:

        while b[i]>=c[cst] and cst<n-1:

            cst=cst+1

#            print("c2:",cst-1,c[cst-1],i,b[i])

#    print(ast,i,n-cst)

    icnt=icnt+(ast)*(n-cst)

    

print(icnt)
from bisect import bisect_left,bisect

 

n=int(eval(input()))

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

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

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

lenc=len(c)



a.sort()

b.sort()

c.sort()



jsum=0

for j in b:

    ai=bisect(a,j-1)

    ci=lenc-bisect_left(c,j+1)

#    print(j,ai,ci)

    jsum+=ai*ci



print(jsum)
icase = 0
if icase == 0:
    n = int(eval(input()))  # 数値入力 「N」だけの入力のとき
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
elif icase == 1:
    n = 2
    a = [1, 5]
    b = [2, 4]
    c = [3, 6]
elif icase == 2:
    n = 6
    a = [3, 14, 159, 2, 6, 53]
    b = [58, 9, 79, 323, 84, 6]
    c = [2643, 383, 2, 79, 50, 288]
a.sort()
b.sort()
c.sort()
icnt = 0
ast = 0
cst = 0
for i in range(n):
    if a[n - 1] <= b[i]:
        ast = n
    #        print("a1:",ast-1,a[ast-1],i,b[i])
    elif a[0] >= b[i]:
        ast = 0
    #        print("a1:",ast-1,a[ast-1],i,b[i])
    else:
        while a[ast] < b[i] and ast < n - 1:
            ast = ast + 1
    #            print("a2:",ast-1,a[ast-1],i,b[i])
    if b[i] < c[0]:
        cst = 0
    elif b[i] >= c[n - 1]:
        cst = n
    #        print("c1:",cst,c[cst],i,b[i])
    else:
        while b[i] >= c[cst] and cst < n - 1:
            cst = cst + 1
    #            print("c2:",cst-1,c[cst-1],i,b[i])
    #    print(ast,i,n-cst)
    icnt = icnt + (ast) * (n - cst)
print(icnt)

from bisect import bisect_left, bisect

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
lenc = len(c)
a.sort()
b.sort()
c.sort()
jsum = 0
for j in b:
    ai = bisect(a, j - 1)
    ci = lenc - bisect_left(c, j + 1)
    #    print(j,ai,ci)
    jsum += ai * ci
print(jsum)

-icase = 0 -if icase == 0: -    n = int(eval(input()))  # 数値入力 「N」だけの入力のとき -    a = list(map(int, input().split())) -    b = list(map(int, input().split())) -    c = list(map(int, input().split())) -elif icase == 1: -    n = 2 -    a = [1, 5] -    b = [2, 4] -    c = [3, 6] -elif icase == 2: -    n = 6 -    a = [3, 14, 159, 2, 6, 53] -    b = [58, 9, 79, 323, 84, 6] -    c = [2643, 383, 2, 79, 50, 288] +from bisect import bisect_left, bisect + +n = int(eval(input())) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = list(map(int, input().split())) +lenc = len(c) -icnt = 0 -ast = 0 -cst = 0 -for i in range(n): -    if a[n - 1] <= b[i]: -        ast = n -    #        print("a1:",ast-1,a[ast-1],i,b[i]) -    elif a[0] >= b[i]: -        ast = 0 -    #        print("a1:",ast-1,a[ast-1],i,b[i]) -    else: -        while a[ast] < b[i] and ast < n - 1: -            ast = ast + 1 -    #            print("a2:",ast-1,a[ast-1],i,b[i]) -    if b[i] < c[0]: -        cst = 0 -    elif b[i] >= c[n - 1]: -        cst = n -    #        print("c1:",cst,c[cst],i,b[i]) -    else: -        while b[i] >= c[cst] and cst < n - 1: -            cst = cst + 1 -    #            print("c2:",cst-1,c[cst-1],i,b[i]) -    #    print(ast,i,n-cst) -    icnt = icnt + (ast) * (n - cst) -print(icnt) +jsum = 0 +for j in b: +    ai = bisect(a, j - 1) +    ci = lenc - bisect_left(c, j + 1) +    #    print(j,ai,ci) +    jsum += ai * ci +print(jsum)