def getN():

    return int(eval(input()))

def getNM():

    return list(map(int, input().split()))

def getList():

    return list(map(int, input().split()))

def getArray(intn):

    return [int(eval(input())) for i in range(intn)]

def input():

    return sys.stdin.readline().rstrip()



from collections import defaultdict, deque, Counter

from sys import exit

import heapq

import math

from fractions import gcd

import copy

from itertools import permutations

from operator import mul

from functools import reduce

from bisect import bisect_left, bisect_right



import sys

sys.setrecursionlimit(1000000000)

mod = 10 ** 9 + 7



from itertools import permutations

from math import factorial, hypot



#############

# Main Code #

#############



N = getN()

top = getList()

middle = getList()

bottom = getList()



top.sort()

middle.sort()

bottom.sort()



# i未満

on_mid = [0]

for i in range(N):

    index_mid = bisect_left(top, middle[i])

    on_mid.append(on_mid[i] + index_mid)



ans = 0

for j in range(N):

    index_bot = bisect_left(middle, bottom[j])

    # on_midの最初の0を取り除いてないのでインデックスが一つずれる

    ans += on_mid[index_bot]

print(ans)
def getN():

    return int(eval(input()))

def getNM():

    return list(map(int, input().split()))

def getList():

    return list(map(int, input().split()))

def getArray(intn):

    return [int(eval(input())) for i in range(intn)]

def input():

    return sys.stdin.readline().rstrip()

def rand_N(ran1, ran2):

    return random.randint(ran1, ran2)

def rand_List(ran1, ran2, rantime):

    return [random.randint(ran1, ran2) for i in range(rantime)]

def rand_ints_nodup(ran1, ran2, rantime):

  ns = []

  while len(ns) < rantime:

    n = random.randint(ran1, ran2)

    if not n in ns:

      ns.append(n)

  return sorted(ns)



def rand_query(ran1, ran2, rantime):

  r_query = []

  while len(r_query) < rantime:

    n_q = rand_ints_nodup(ran1, ran2, 2)

    if not n_q in r_query:

      r_query.append(n_q)

  return sorted(r_query)



from collections import defaultdict, deque, Counter

from sys import exit

from decimal import *

import heapq

import math

from fractions import gcd

import random

import string

import copy

from itertools import combinations, permutations, product

from operator import mul

from functools import reduce

from bisect import bisect_left, bisect_right



import sys

sys.setrecursionlimit(1000000000)

mod = 10 ** 9 + 7



#############

# Main Code #

#############



def less_than(array, x):

    # arrayの中のx未満のものの個数

    # arrayの中のx未満のもののうちの最大値

    index = bisect_left(array, x)

    if index == 0:

        less_than_int = -float('inf')

    else:

        less_than_int = array[index - 1]

    return [index, less_than_int]



N = getN()

up = getList()

up.sort()

mid = getList()

mid.sort()

low = getList()

low.sort()



# 中段のパーツに載せられる上段のパーツの数

mid_imos = [0] * N

for i in range(N):

    mid_imos[i] = less_than(up, mid[i])[0]



for i in range(N - 1):

    mid_imos[i + 1] += mid_imos[i]



low_imos = [0] * N

for i in range(N):

    ind = less_than(mid, low[i])[0]

    if ind > 0:

        low_imos[i] = mid_imos[ind - 1]

print((sum(low_imos)))
def getN():
    return int(eval(input()))


def getNM():
    return list(map(int, input().split()))


def getList():
    return list(map(int, input().split()))


def getArray(intn):
    return [int(eval(input())) for i in range(intn)]


def input():
    return sys.stdin.readline().rstrip()


from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys

sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############
N = getN()
top = getList()
middle = getList()
bottom = getList()
top.sort()
middle.sort()
bottom.sort()
# i未満
on_mid = [0]
for i in range(N):
    index_mid = bisect_left(top, middle[i])
    on_mid.append(on_mid[i] + index_mid)
ans = 0
for j in range(N):
    index_bot = bisect_left(middle, bottom[j])
    # on_midの最初の0を取り除いてないのでインデックスが一つずれる
    ans += on_mid[index_bot]
print(ans)

def getN():
    return int(eval(input()))


def getNM():
    return list(map(int, input().split()))


def getList():
    return list(map(int, input().split()))


def getArray(intn):
    return [int(eval(input())) for i in range(intn)]


def input():
    return sys.stdin.readline().rstrip()


def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)


def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]


def rand_ints_nodup(ran1, ran2, rantime):
    ns = []
    while len(ns) < rantime:
        n = random.randint(ran1, ran2)
        if not n in ns:
            ns.append(n)
    return sorted(ns)


def rand_query(ran1, ran2, rantime):
    r_query = []
    while len(r_query) < rantime:
        n_q = rand_ints_nodup(ran1, ran2, 2)
        if not n_q in r_query:
            r_query.append(n_q)
    return sorted(r_query)


from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys

sys.setrecursionlimit(1000000000)
mod = 10**9 + 7
#############
# Main Code #
#############
def less_than(array, x):
    # arrayの中のx未満のものの個数
    # arrayの中のx未満のもののうちの最大値
    index = bisect_left(array, x)
    if index == 0:
        less_than_int = -float("inf")
    else:
        less_than_int = array[index - 1]
    return [index, less_than_int]


N = getN()
up = getList()
up.sort()
mid = getList()
mid.sort()
low = getList()
low.sort()
# 中段のパーツに載せられる上段のパーツの数
mid_imos = [0] * N
for i in range(N):
    mid_imos[i] = less_than(up, mid[i])[0]
for i in range(N - 1):
    mid_imos[i + 1] += mid_imos[i]
low_imos = [0] * N
for i in range(N):
    ind = less_than(mid, low[i])[0]
    if ind > 0:
        low_imos[i] = mid_imos[ind - 1]
print((sum(low_imos)))

+def rand_N(ran1, ran2): +    return random.randint(ran1, ran2) + + +def rand_List(ran1, ran2, rantime): +    return [random.randint(ran1, ran2) for i in range(rantime)] + + +def rand_ints_nodup(ran1, ran2, rantime): +    ns = [] +    while len(ns) < rantime: +        n = random.randint(ran1, ran2) +        if not n in ns: +            ns.append(n) +    return sorted(ns) + + +def rand_query(ran1, ran2, rantime): +    r_query = [] +    while len(r_query) < rantime: +        n_q = rand_ints_nodup(ran1, ran2, 2) +        if not n_q in r_query: +            r_query.append(n_q) +    return sorted(r_query) + + +from decimal import * +import random +import string -from itertools import permutations +from itertools import combinations, permutations, product -from itertools import permutations -from math import factorial, hypot - +def less_than(array, x): +    # arrayの中のx未満のものの個数 +    # arrayの中のx未満のもののうちの最大値 +    index = bisect_left(array, x) +    if index == 0: +        less_than_int = -float("inf") +    else: +        less_than_int = array[index - 1] +    return [index, less_than_int] + + -top = getList() -middle = getList() -bottom = getList() -top.sort() -middle.sort() -bottom.sort() -# i未満 -on_mid = [0] +up = getList() +up.sort() +mid = getList() +mid.sort() +low = getList() +low.sort() +# 中段のパーツに載せられる上段のパーツの数 +mid_imos = [0] * N -    index_mid = bisect_left(top, middle[i]) -    on_mid.append(on_mid[i] + index_mid) -ans = 0 -for j in range(N): -    index_bot = bisect_left(middle, bottom[j]) -    # on_midの最初の0を取り除いてないのでインデックスが一つずれる -    ans += on_mid[index_bot] -print(ans) +    mid_imos[i] = less_than(up, mid[i])[0] +for i in range(N - 1): +    mid_imos[i + 1] += mid_imos[i] +low_imos = [0] * N +for i in range(N): +    ind = less_than(mid, low[i])[0] +    if ind > 0: +        low_imos[i] = mid_imos[ind - 1] +print((sum(low_imos)))