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)

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



# Bの値を決める

# Bより小さいAを二分探索、Bより大きいAを二分探索、その積を各Bごとに求めて足していく



import bisect

ans=0

for i in range(len(B)):

  apos=bisect.bisect_left(A,B[i])

  cpos=bisect.bisect_right(C,B[i])

  ans+=(apos)*(N-cpos)

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)

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())))
# Bの値を決める
# Bより小さいAを二分探索、Bより大きいAを二分探索、その積を各Bごとに求めて足していく
import bisect

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

-N = list(map(int, input().split())) +N = int(eval(input())) -B = list(map(int, input().split())) +B = 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 - +# Bの値を決める +# Bより小さいAを二分探索、Bより大きいAを二分探索、その積を各Bごとに求めて足していく +import bisect -    data = B[i] -    ans += countA(data, A) * countC(data, C) +    apos = bisect.bisect_left(A, B[i]) +    cpos = bisect.bisect_right(C, B[i]) +    ans += (apos) * (N - cpos)