from bisect import*

(N,),A,B,C=[sorted(map(int,input().split()))for _ in range(4)]

w,i=[0]*(N+1),N

while i:i-=1;w[i]=w[i+1]+N-bisect(C,B[i])

print((sum(w[bisect(B,a)]for a in A)))
from bisect import*

(N,),A,B,C=[sorted(map(int,input().split()))for _ in[0]*4]

print((sum(bisect_left(A,b)*(N-bisect(C,b))for b in B)))
from bisect import *

(N,), A, B, C = [sorted(map(int, input().split())) for _ in range(4)]
w, i = [0] * (N + 1), N
while i:
    i -= 1
    w[i] = w[i + 1] + N - bisect(C, B[i])
print((sum(w[bisect(B, a)] for a in A)))

from bisect import *

(N,), A, B, C = [sorted(map(int, input().split())) for _ in [0] * 4]
print((sum(bisect_left(A, b) * (N - bisect(C, b)) for b in B)))

-(N,), A, B, C = [sorted(map(int, input().split())) for _ in range(4)] -w, i = [0] * (N + 1), N -while i: -    i -= 1 -    w[i] = w[i + 1] + N - bisect(C, B[i]) -print((sum(w[bisect(B, a)] for a in A))) +(N,), A, B, C = [sorted(map(int, input().split())) for _ in [0] * 4] +print((sum(bisect_left(A, b) * (N - bisect(C, b)) for b in B)))