from bisect import bisect_left,bisect_right

n=int(eval(input()))

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

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

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

a.sort()

b.sort()

c.sort()

ans=0

for i in range(n):

    ai=bisect_left(a,b[i])

    ci=bisect_right(c,b[i])

    ans+=ai*(n-ci)

print(ans)



n=int(eval(input()))

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

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

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

a.sort()

b.sort()

c.sort()

from bisect import bisect_left,bisect_right

ans=0

for i in range(n):

  ida=bisect_left(a,b[i])

  idc=bisect_right(c,b[i])

  ans+=ida*(n-idc)

print(ans)
from bisect import bisect_left, bisect_right

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(n):
    ai = bisect_left(a, b[i])
    ci = bisect_right(c, b[i])
    ans += ai * (n - ci)
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
from bisect import bisect_left, bisect_right

ans = 0
for i in range(n):
    ida = bisect_left(a, b[i])
    idc = bisect_right(c, b[i])
    ans += ida * (n - idc)
print(ans)

-from bisect import bisect_left, bisect_right - +from bisect import bisect_left, bisect_right + -    ai = bisect_left(a, b[i]) -    ci = bisect_right(c, b[i]) -    ans += ai * (n - ci) +    ida = bisect_left(a, b[i]) +    idc = bisect_right(c, b[i]) +    ans += ida * (n - idc)