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

b.sort()

c.sort()

memo = [0]*(n+1)

for i in range(n):

    memo[bisect.bisect_left(b,c[i])] += 1

for i in range(n-1,-1,-1):

    memo[i] += memo[i+1]

for i in range(n-1,-1,-1):

    memo[i] += memo[i+1]

memo = memo[1:]+[0]

ans = 0



for i in range(n):

    ans += memo[bisect.bisect_right(b,a[i])]

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

b.sort()

c.sort()

ans = 0

for i in range(n):

    t = b[i]

    ci = bisect.bisect_right(c,t)

    ai = bisect.bisect_left(a,t)

    ans += ai*(n-ci)

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()
b.sort()
c.sort()
memo = [0] * (n + 1)
for i in range(n):
    memo[bisect.bisect_left(b, c[i])] += 1
for i in range(n - 1, -1, -1):
    memo[i] += memo[i + 1]
for i in range(n - 1, -1, -1):
    memo[i] += memo[i + 1]
memo = memo[1:] + [0]
ans = 0
for i in range(n):
    ans += memo[bisect.bisect_right(b, a[i])]
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()
b.sort()
c.sort()
ans = 0
for i in range(n):
    t = b[i]
    ci = bisect.bisect_right(c, t)
    ai = bisect.bisect_left(a, t)
    ans += ai * (n - ci)
print(ans)

-memo = [0] * (n + 1) -for i in range(n): -    memo[bisect.bisect_left(b, c[i])] += 1 -for i in range(n - 1, -1, -1): -    memo[i] += memo[i + 1] -for i in range(n - 1, -1, -1): -    memo[i] += memo[i + 1] -memo = memo[1:] + [0] -    ans += memo[bisect.bisect_right(b, a[i])] +    t = b[i] +    ci = bisect.bisect_right(c, t) +    ai = bisect.bisect_left(a, t) +    ans += ai * (n - ci)