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:

    x=bisect.bisect_left(a,i)

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

    ans+=x*y

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)

    B=len(b)-bisect.bisect_right(c,i)

    ans+=A*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:
    x = bisect.bisect_left(a, i)
    y = n - bisect.bisect_right(c, i)
    ans += x * y
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)
    B = len(b) - bisect.bisect_right(c, i)
    ans += A * B
print(ans)

-    x = bisect.bisect_left(a, i) -    y = n - bisect.bisect_right(c, i) -    ans += x * y +    A = bisect.bisect_left(a, i) +    B = len(b) - bisect.bisect_right(c, i) +    ans += A * B