import bisect

n=eval(input())

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

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

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

ans=0

for B in b:

  ans+=(bisect.bisect_left(a,B))*(len(c)-(bisect.bisect_right(c,B)))

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

ans=0

for i in b:

  A=bisect.bisect_left(a,i)

  C=bisect.bisect(c,i)

  ans+=A*(n-C)

print(ans)

import bisect

n = eval(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for B in b:
    ans += (bisect.bisect_left(a, B)) * (len(c) - (bisect.bisect_right(c, B)))
print(ans)

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())))
ans = 0
for i in b:
    A = bisect.bisect_left(a, i)
    C = bisect.bisect(c, i)
    ans += A * (n - C)
print(ans)

-n = eval(input()) +n = int(eval(input())) -for B in b: -    ans += (bisect.bisect_left(a, B)) * (len(c) - (bisect.bisect_right(c, B))) +for i in b: +    A = bisect.bisect_left(a, i) +    C = bisect.bisect(c, i) +    ans += A * (n - C)