import bisect

n=int(eval(input()))

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

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

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

a.sort()

c.sort()



ans=0

for i in b:

    up=bisect.bisect_left(a, i)

    dn=n-bisect.bisect_right(c, i)

    ans+=up*dn



print(ans)

import numpy as np

N = int(eval(input()))

A = np.array(input().split(), dtype=int)

B = np.array(input().split(), dtype=int)

C = np.array(input().split(), dtype=int)

A.sort()

B.sort()

C.sort()



CB = np.searchsorted(B, C, side="left")

BA = np.searchsorted(A, B, side="left")

tmp = [0]+BA.cumsum().tolist()

tmp = np.array(tmp)



ans = tmp[CB].sum()

print(ans)

import bisect

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in b:
    up = bisect.bisect_left(a, i)
    dn = n - bisect.bisect_right(c, i)
    ans += up * dn
print(ans)

import numpy as np

N = int(eval(input()))
A = np.array(input().split(), dtype=int)
B = np.array(input().split(), dtype=int)
C = np.array(input().split(), dtype=int)
A.sort()
B.sort()
C.sort()
CB = np.searchsorted(B, C, side="left")
BA = np.searchsorted(A, B, side="left")
tmp = [0] + BA.cumsum().tolist()
tmp = np.array(tmp)
ans = tmp[CB].sum()
print(ans)

-import bisect +import numpy as np -n = int(eval(input())) -a = list(map(int, input().split())) -b = list(map(int, input().split())) -c = list(map(int, input().split())) -a.sort() -c.sort() -ans = 0 -for i in b: -    up = bisect.bisect_left(a, i) -    dn = n - bisect.bisect_right(c, i) -    ans += up * dn +N = int(eval(input())) +A = np.array(input().split(), dtype=int) +B = np.array(input().split(), dtype=int) +C = np.array(input().split(), dtype=int) +A.sort() +B.sort() +C.sort() +CB = np.searchsorted(B, C, side="left") +BA = np.searchsorted(A, B, side="left") +tmp = [0] + BA.cumsum().tolist() +tmp = np.array(tmp) +ans = tmp[CB].sum()