from bisect import bisect_left

from collections import defaultdict



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



AB = defaultdict(int)



for b in B:

    AB[b] = bisect_left(A, b)



sumAB = defaultdict(int)

sumAB[0] = 0

s = 0

for b in B:

    s += AB[b]

    sumAB[b] = s



B.insert(0, 0)

ans = 0

for c in C:

    r = bisect_left(B, c)

    ans += sumAB[B[r - 1]]



print(ans)
import sys

import heapq

from operator import itemgetter

from collections import deque, defaultdict, Counter

from bisect import bisect_left, bisect_right

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7

INF = float('inf')



def sol():

    N = int(eval(input()))

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

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

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



    A.sort()

    C.sort()



    ans = 0

    for b in B:

        a = bisect_left(A, b)

        c = bisect_right(C, b)

        ans += a * (N - c)



    print(ans)



sol()
from bisect import bisect_left
from collections import defaultdict

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()
AB = defaultdict(int)
for b in B:
    AB[b] = bisect_left(A, b)
sumAB = defaultdict(int)
sumAB[0] = 0
s = 0
for b in B:
    s += AB[b]
    sumAB[b] = s
B.insert(0, 0)
ans = 0
for c in C:
    r = bisect_left(B, c)
    ans += sumAB[B[r - 1]]
print(ans)

import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")


def sol():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    C.sort()
    ans = 0
    for b in B:
        a = bisect_left(A, b)
        c = bisect_right(C, b)
        ans += a * (N - c)
    print(ans)


sol()

-from bisect import bisect_left -from collections import defaultdict +import sys +import heapq +from operator import itemgetter +from collections import deque, defaultdict, Counter +from bisect import bisect_left, bisect_right -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() -AB = defaultdict(int) -for b in B: -    AB[b] = bisect_left(A, b) -sumAB = defaultdict(int) -sumAB[0] = 0 -s = 0 -for b in B: -    s += AB[b] -    sumAB[b] = s -B.insert(0, 0) -ans = 0 -for c in C: -    r = bisect_left(B, c) -    ans += sumAB[B[r - 1]] -print(ans) +input = sys.stdin.readline +sys.setrecursionlimit(10**7) +MOD = 10**9 + 7 +INF = float("inf") + + +def sol(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    B = list(map(int, input().split())) +    C = list(map(int, input().split())) +    A.sort() +    C.sort() +    ans = 0 +    for b in B: +        a = bisect_left(A, b) +        c = bisect_right(C, b) +        ans += a * (N - c) +    print(ans) + + +sol()