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

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

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

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

 

def countA(target,L):

  ok=-1

  ng=len(L)

  while abs(ok-ng)>1:

    mid=(ok+ng)//2

    if L[mid]<target:

      ok=mid

    else:

      ng=mid

  return (ok+1)

 

def countC(target,L):

  ok=len(L)

  ng=-1

  while abs(ok-ng)>1:

    mid=(ok+ng)//2

    if L[mid]>target:

      ok=mid

    else:

      ng=mid

  return len(L)-ok

 

ans=0

for i in range(len(B)):

  data=B[i]

  ans+=(countA(data,A)*countC(data,C))

  

print(ans)
def nibu_A(list,item):

    high=len(list)

    low=-1

    while abs(high-low) > 1:

        mid=(high+low)//2



        if list[mid] < item:

            low= mid

        else:

            high=mid

    return (low+1)

def nibu_c(list,item):

    high= len(list)

    low=-1

    while abs(high-low)>1:

        mid=(high+low)//2

        if list[mid]>item:

             high = mid

        else:

            low=mid

    return len(list)-high





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

    data=B[i]

    ans+=(nibu_A(A,data)*nibu_c(C,data))

print(ans)

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


def countA(target, L):
    ok = -1
    ng = len(L)
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if L[mid] < target:
            ok = mid
        else:
            ng = mid
    return ok + 1


def countC(target, L):
    ok = len(L)
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if L[mid] > target:
            ok = mid
        else:
            ng = mid
    return len(L) - ok


ans = 0
for i in range(len(B)):
    data = B[i]
    ans += countA(data, A) * countC(data, C)
print(ans)

def nibu_A(list, item):
    high = len(list)
    low = -1
    while abs(high - low) > 1:
        mid = (high + low) // 2
        if list[mid] < item:
            low = mid
        else:
            high = mid
    return low + 1


def nibu_c(list, item):
    high = len(list)
    low = -1
    while abs(high - low) > 1:
        mid = (high + low) // 2
        if list[mid] > item:
            high = mid
        else:
            low = mid
    return len(list) - high


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):
    data = B[i]
    ans += nibu_A(A, data) * nibu_c(C, data)
print(ans)

-N = list(map(int, input().split())) +def nibu_A(list, item): +    high = len(list) +    low = -1 +    while abs(high - low) > 1: +        mid = (high + low) // 2 +        if list[mid] < item: +            low = mid +        else: +            high = mid +    return low + 1 + + +def nibu_c(list, item): +    high = len(list) +    low = -1 +    while abs(high - low) > 1: +        mid = (high + low) // 2 +        if list[mid] > item: +            high = mid +        else: +            low = mid +    return len(list) - high + + +n = int(eval(input())) - - -def countA(target, L): -    ok = -1 -    ng = len(L) -    while abs(ok - ng) > 1: -        mid = (ok + ng) // 2 -        if L[mid] < target: -            ok = mid -        else: -            ng = mid -    return ok + 1 - - -def countC(target, L): -    ok = len(L) -    ng = -1 -    while abs(ok - ng) > 1: -        mid = (ok + ng) // 2 -        if L[mid] > target: -            ok = mid -        else: -            ng = mid -    return len(L) - ok - - -for i in range(len(B)): +for i in range(n): -    ans += countA(data, A) * countC(data, C) +    ans += nibu_A(A, data) * nibu_c(C, data)