import bisect

n = int(eval(input()))

a,b,c = [sorted(map(int,input().split())) for _ in "abc"]

print((sum([bisect.bisect_left(a,x)*(n-bisect.bisect_right(c,x)) for x in b])))
from bisect import *

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

print((sum(bisect_left(A,b)*(N-bisect_right(C,b)) for b in B)))
import bisect

n = int(eval(input()))
a, b, c = [sorted(map(int, input().split())) for _ in "abc"]
print((sum([bisect.bisect_left(a, x) * (n - bisect.bisect_right(c, x)) for x in b])))

from bisect import *

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())))
print((sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)))

-import bisect +from bisect import * -n = int(eval(input())) -a, b, c = [sorted(map(int, input().split())) for _ in "abc"] -print((sum([bisect.bisect_left(a, x) * (n - bisect.bisect_right(c, x)) for x in b]))) +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()))) +print((sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)))