from bisect import bisect_left,bisect_right;N=int(eval(input()));A,B,C=[list(map(int,input().split())) for _ in "ABC"];A.sort();C.sort();print((sum([bisect_left(A,i)*(N-bisect_right(C,i)) for i in B])))
import bisect;N=int(eval(input()));A,B,C=[sorted(list(map(int,input().split()))) for _ in "ABC"];print((sum([bisect.bisect_left(A,i)*(N-bisect.bisect_right(C,i)) for i in B])))

from bisect import bisect_left, bisect_right

N = int(eval(input()))
A, B, C = [list(map(int, input().split())) for _ in "ABC"]
A.sort()
C.sort()
print((sum([bisect_left(A, i) * (N - bisect_right(C, i)) for i in B])))

import bisect

N = int(eval(input()))
A, B, C = [sorted(list(map(int, input().split()))) for _ in "ABC"]
print((sum([bisect.bisect_left(A, i) * (N - bisect.bisect_right(C, i)) for i in B])))

-from bisect import bisect_left, bisect_right +import bisect -A, B, C = [list(map(int, input().split())) for _ in "ABC"] -A.sort() -C.sort() -print((sum([bisect_left(A, i) * (N - bisect_right(C, i)) for i in B]))) +A, B, C = [sorted(list(map(int, input().split()))) for _ in "ABC"] +print((sum([bisect.bisect_left(A, i) * (N - bisect.bisect_right(C, i)) for i in B])))