# -*- coding: utf-8 -*-

 

import bisect

 

n = int(eval(input()))

 

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

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

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

 

A.sort()

B.sort()

C.sort()

 

Ac, Cc = [0]*n, [0]*n

# Ap, Cp = 0, 0

 

for i in range(n):

    Ac[i] = bisect.bisect_left(A, B[i])#[Ap:], B[i])

    # Ac[i], Ap = index + Ap, index + Ap

    Cc[i] = n - bisect.bisect_right(C, B[i])#[Cp:], B[i])

    # Cc[i], Cp = n - index - Cp, index + Cp

 

 

count = 0

for i in range(n):

    count += Ac[i]*Cc[i]

 

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



print((sum([bisect.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B])))

# -*- coding: utf-8 -*-
import bisect

n = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
Ac, Cc = [0] * n, [0] * n
# Ap, Cp = 0, 0
for i in range(n):
    Ac[i] = bisect.bisect_left(A, B[i])  # [Ap:], B[i])
    # Ac[i], Ap = index + Ap, index + Ap
    Cc[i] = n - bisect.bisect_right(C, B[i])  # [Cp:], B[i])
    # Cc[i], Cp = n - index - Cp, index + Cp
count = 0
for i in range(n):
    count += Ac[i] * Cc[i]
print(count)

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

-# -*- coding: utf-8 -*- -n = int(eval(input())) -A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -B.sort() -C.sort() -Ac, Cc = [0] * n, [0] * n -# Ap, Cp = 0, 0 -for i in range(n): -    Ac[i] = bisect.bisect_left(A, B[i])  # [Ap:], B[i]) -    # Ac[i], Ap = index + Ap, index + Ap -    Cc[i] = n - bisect.bisect_right(C, B[i])  # [Cp:], B[i]) -    # Cc[i], Cp = n - index - Cp, index + Cp -count = 0 -for i in range(n): -    count += Ac[i] * Cc[i] -print(count) +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.bisect_left(A, b) * (N - bisect.bisect(C, b)) for b in B])))