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

sm=0

for j in B:

  sm+=bisect.bisect_left(A,j)*(n-bisect.bisect_right(C,j))

print(sm)

  
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 i in b:

  cnt+=bisect.bisect_left(a,i)*(n-bisect.bisect_right(c,i))

print(cnt)
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())))
sm = 0
for j in B:
    sm += bisect.bisect_left(A, j) * (n - bisect.bisect_right(C, j))
print(sm)

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 i in b:
    cnt += bisect.bisect_left(a, i) * (n - bisect.bisect_right(c, i))
print(cnt)

-A = sorted(list(map(int, input().split()))) -B = sorted(list(map(int, input().split()))) -C = sorted(list(map(int, input().split()))) -sm = 0 -for j in B: -    sm += bisect.bisect_left(A, j) * (n - bisect.bisect_right(C, j)) -print(sm) +a = sorted(list(map(int, input().split()))) +b = sorted(list(map(int, input().split()))) +c = sorted(list(map(int, input().split()))) +cnt = 0 +for i in b: +    cnt += bisect.bisect_left(a, i) * (n - bisect.bisect_right(c, i)) +print(cnt)