import bisect

n = int(eval(input()))

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

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

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



al.sort()

bl.sort()

cl.sort()



cnt = 0

for b in bl:

    a_num = bisect.bisect_left(al,b)

    c_num = n - bisect.bisect_right(cl,b)

    cnt += a_num*c_num

    # cnt += c_num



print(cnt)
import bisect

n = int(eval(input()))

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

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

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



al.sort()

bl.sort()

cl.sort()



ans = 0

for b in bl:

    a_num = bisect.bisect_left(al,b)

    c_num = n - bisect.bisect_right(cl,b)

    ans += a_num*c_num



print(ans)
import bisect

n = int(eval(input()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
cnt = 0
for b in bl:
    a_num = bisect.bisect_left(al, b)
    c_num = n - bisect.bisect_right(cl, b)
    cnt += a_num * c_num
    # cnt += c_num
print(cnt)

import bisect

n = int(eval(input()))
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
ans = 0
for b in bl:
    a_num = bisect.bisect_left(al, b)
    c_num = n - bisect.bisect_right(cl, b)
    ans += a_num * c_num
print(ans)

-cnt = 0 +ans = 0 -    cnt += a_num * c_num -    # cnt += c_num -print(cnt) +    ans += a_num * c_num +print(ans)