from bisect import bisect_right, bisect_left



n = int(eval(input()))



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

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

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



ans = 0

for x in b:

  ans += bisect_left(a, x) * (n - bisect_right(c, x))



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 b in B:

    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))



print(ans)
from bisect import bisect_right, bisect_left

n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
ans = 0
for x in b:
    ans += bisect_left(a, x) * (n - bisect_right(c, x))
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 b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
print(ans)

-from bisect import bisect_right, bisect_left +import bisect -a = sorted(list(map(int, input().split()))) -b = list(map(int, input().split())) -c = sorted(list(map(int, input().split()))) +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) -for x in b: -    ans += bisect_left(a, x) * (n - bisect_right(c, x)) +for b in B: +    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))