n = int(eval(input()))

a,b,c = [sorted(list(map(int,input().split())),reverse=True) for i in range(3)]

comp1 = []

i,j = 0,0

cnt = 0

while i<n:

    while j<n and b[j]>a[i]:

        cnt+=1

        j+=1

    comp1.append(cnt)

    i+=1

comp2 = []

i,j = 0,0

cnt = 0

while i<n:

    while j<n and c[j]>b[i]:

        cnt+=1

        j+=1

    comp2.append(cnt)

    i+=1

x = [0]

for i in range(n):

    x.append(x[i]+comp2[i])

ans = 0

for i in comp1:

    ans += x[i]

print(ans)
import bisect

n = int(eval(input()))

a,b,c = [sorted(list(map(int,input().split()))) for i in range(3)]

ans = 0

cnt = [0]

[cnt.append(cnt[i]+bisect.bisect_left(a,b[i])) for i in range(n)]

for i in range(n):

    index = bisect.bisect_left(b,c[i])

    ans += cnt[index] 

print(ans)
n = int(eval(input()))
a, b, c = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)]
comp1 = []
i, j = 0, 0
cnt = 0
while i < n:
    while j < n and b[j] > a[i]:
        cnt += 1
        j += 1
    comp1.append(cnt)
    i += 1
comp2 = []
i, j = 0, 0
cnt = 0
while i < n:
    while j < n and c[j] > b[i]:
        cnt += 1
        j += 1
    comp2.append(cnt)
    i += 1
x = [0]
for i in range(n):
    x.append(x[i] + comp2[i])
ans = 0
for i in comp1:
    ans += x[i]
print(ans)

import bisect

n = int(eval(input()))
a, b, c = [sorted(list(map(int, input().split()))) for i in range(3)]
ans = 0
cnt = [0]
[cnt.append(cnt[i] + bisect.bisect_left(a, b[i])) for i in range(n)]
for i in range(n):
    index = bisect.bisect_left(b, c[i])
    ans += cnt[index]
print(ans)

+import bisect + -a, b, c = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)] -comp1 = [] -i, j = 0, 0 -cnt = 0 -while i < n: -    while j < n and b[j] > a[i]: -        cnt += 1 -        j += 1 -    comp1.append(cnt) -    i += 1 -comp2 = [] -i, j = 0, 0 -cnt = 0 -while i < n: -    while j < n and c[j] > b[i]: -        cnt += 1 -        j += 1 -    comp2.append(cnt) -    i += 1 -x = [0] +a, b, c = [sorted(list(map(int, input().split()))) for i in range(3)] +ans = 0 +cnt = [0] +[cnt.append(cnt[i] + bisect.bisect_left(a, b[i])) for i in range(n)] -    x.append(x[i] + comp2[i]) -ans = 0 -for i in comp1: -    ans += x[i] +    index = bisect.bisect_left(b, c[i]) +    ans += cnt[index]