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

d = [-1] * n

ansum = 0

def stat(array,par):

    return bisect.bisect(array,par)



for i in range(n):

    indexC = stat(c,b[i])

    d[i] = max(0,n-indexC) 

for i in range(n-1):

    d[n-i-2] += d[n-i-1]

for A in a:

    index = stat(b,A)

    if index < n:

        ansum += d[index]

print(ansum)

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

ansum = 0

for B in b:

    index = bisect.bisect_left(a,B)

    index2= bisect.bisect_right(c,B)

    ansum += index*(n-index2)

print(ansum)

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())))
d = [-1] * n
ansum = 0


def stat(array, par):
    return bisect.bisect(array, par)


for i in range(n):
    indexC = stat(c, b[i])
    d[i] = max(0, n - indexC)
for i in range(n - 1):
    d[n - i - 2] += d[n - i - 1]
for A in a:
    index = stat(b, A)
    if index < n:
        ansum += d[index]
print(ansum)

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())))
ansum = 0
for B in b:
    index = bisect.bisect_left(a, B)
    index2 = bisect.bisect_right(c, B)
    ansum += index * (n - index2)
print(ansum)

-d = [-1] * n - - -def stat(array, par): -    return bisect.bisect(array, par) - - -for i in range(n): -    indexC = stat(c, b[i]) -    d[i] = max(0, n - indexC) -for i in range(n - 1): -    d[n - i - 2] += d[n - i - 1] -for A in a: -    index = stat(b, A) -    if index < n: -        ansum += d[index] +for B in b: +    index = bisect.bisect_left(a, B) +    index2 = bisect.bisect_right(c, B) +    ansum += index * (n - index2)