CodeEff/ECCO huggingface dataset:
# Original solution
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()
ans=0
for a in A:
  bidx=bisect.bisect_right(B,a)
  if bidx==len(B): break
  for b in B[bidx:]:
    cidx=bisect.bisect_right(C,b)
    if cidx==len(B): break
    ans+=len(C)-cidx
print(ans)


# Optimized solution
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()
ans=0
for b in B:
  aidx=bisect.bisect_left(A,b)
  cidx=bisect.bisect_right(C,b)
  ans+=aidx*(len(C)-cidx)
print(ans)
# Original solution
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()

b_ptn = [0] * (N)
for idx, b in enumerate(B):
  cnt = 0
  for a in A:
    if a < b:
      cnt += 1
    else:
      break
  b_ptn[idx] = cnt
ans = 0
for c in C:
  for idx, b in enumerate(B):
    if b >= c:
      break
    if idx == N-1:
      ans += b_ptn[idx]
      break
    ans += b_ptn[idx]
print(ans)


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

nums = []
for idx in range(N):
  nums.append((1, A[idx]))
  nums.append((2, B[idx]))
  nums.append((3, C[idx]))
nums.sort(key=lambda x:(x[1], -x[0]))
sum_a = 0
sum_b = 0
sum_c = 0
for idx in range(3*N):
  if nums[idx][0] == 1:
    sum_a += 1
  elif nums[idx][0] == 2:
    sum_b += sum_a
  elif nums[idx][0] == 3:
    sum_c += sum_b
print(sum_c)
# Original solution
import bisect

N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
B.sort()
C.sort()
cnt = 0
for a in A:
  pos_b = bisect.bisect_right(B, a)
  for pb in range(pos_b, N):
    pos_c = bisect.bisect_right(C, B[pb])
    cnt += N-pos_c
    if pos_c == N-1:
      break
print(cnt)

# Optimized solution
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()
C.sort()
cnt = 0
for b in B:
  pos_a = bisect.bisect_left(A, b)
  pos_c = bisect.bisect_right(C, b)
  cnt += pos_a * (N-pos_c)
print(cnt)
# Original solution
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()
count=0
import bisect
for i in range(0,n):
  tempb=bisect.bisect_right(b,a[i])
  if tempb!=len(b):
    for j in range(tempb,n):
      tempc=bisect.bisect_right(c,b[j])
      tempcl=n-tempc
      count=count+tempcl
print(count)

# Optimized solution
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()
ans=0
for i in range(n):
  temp1=bisect.bisect_left(a,b[i])
  temp2=bisect.bisect(c,b[i])
  ans=ans+temp1*(n-temp2)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

B = sorted(B,reverse=True)
C = sorted(C,reverse=True)
b_list = {-1:0}
for i in range(N):
    for j in range(N):
        if B[i] >= C[j]:
            b_list[i] = j  + b_list[i-1]
            break
        b_list[i] = N + b_list[i-1]
m = 0
for i in range(N):
    for j in range(N-1,-1,-1):
        if B[j] > A[i]:
            m += b_list[j]
            break

print(m)


# Optimized solution
from bisect import bisect_right
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

B = sorted(B)
C = sorted(C)
b_list = {N:0}
for i in range(N-1,-1,-1):
    j = bisect_right(C,B[i])
    b_list[i] = N - j + b_list[i+1]
m = 0
for i in range(N):
    j = bisect_right(B,A[i])
    m += b_list[j]
print(m)
# Original solution
from bisect import bisect_right
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]
    C = [int(i) for i in readline().split()]

    A.sort()
    B.sort()
    C.sort()

    a_ind = []
    b_ind = []
    for i in range(N):
        a_ind.append(bisect_right(B, A[i]))
        b_ind.append(N - bisect_right(C, B[i]))


    b_acc = [0]
    for b in b_ind:
        b_acc.append(b_acc[-1] + b)


    sum_b = b_acc[-1]
    ans = 0
    for i in a_ind:
        ans += sum_b - b_acc[i]

    print(ans)


if __name__ == "__main__":
    main()


# Optimized solution
from bisect import bisect_right, bisect_left
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    B = [int(i) for i in readline().split()]
    C = [int(i) for i in readline().split()]

    A.sort()
    B.sort()
    C.sort()

    ans = 0
    for b in B:
        ans += bisect_left(A, b) * (N - bisect_right(C, b))

    print(ans)


if __name__ == "__main__":
    main()
# Original solution
import bisect

N=int(eval(input()))
A=list(map(int,input().split()))
A=sorted(A)
B=list(map(int,input().split()))
B=sorted(B)
C=list(map(int,input().split()))
C=sorted(C)
count=0
for num in (A):
    a=bisect.bisect_right(B,num)
    for i in range(a,len(B)):
        K=B[i]
        l=bisect.bisect_right(C,K)
        count+=len(C)-l

print(count)

# Optimized solution
import bisect

N=int(eval(input()))
A=list(map(int,input().split()))
A=sorted(A)
B=list(map(int,input().split()))
B=sorted(B)
C=list(map(int,input().split()))
C=sorted(C)
count=0
for num in (B):
    a=bisect.bisect_left(A,num)
    b=bisect.bisect_right(C,num)
    count+=a*(N-b)

print(count)
# Original solution
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())))
cnt = 0

for i in range(n):
  for j in range(n):
    if C[i]>B[j]:
      for k in range(n):
        if B[j]>A[k]:
          cnt+=1

print(cnt)

# Optimized solution
import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n):
    a = bisect.bisect_left(A, B[i])
    c = bisect.bisect_right(C, B[i])
    cnt += a * (n-c)
print(cnt)
# Original solution
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()
ans = 0
for i in C:
    index = bisect.bisect_left(B,i)
    for j in range(index):
        index2 = bisect.bisect_left(A,B[j])
        ans += index2
print(ans)

# Optimized solution
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()

mid_list = [0]*N
for i in range(N):
    index = bisect.bisect_left(A,B[i])
    if i == 0:
        mid_list[i] = index
    else:
        mid_list[i] = mid_list[i-1] + index

ans = 0
for i in range(N):
    index = bisect.bisect_left(B,C[i])
    if index == 0:
        continue
    ans += mid_list[index-1]

print(ans)
# Original solution
import bisect
n = int(eval(input()))
bb = [0] * (n+1)
ans = 0
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()

for i in range(1,n+1):
    bb[i] = bisect.bisect_left(a,b[i-1]) + bb[i-1]

for i in range(n):
    ans += bb[bisect.bisect_left(b,c[i])]
print(ans)

# Optimized solution
import bisect
n = int(eval(input()))
ans = 0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
for i in range(n):
    ans += bisect.bisect_left(a,b[i]) * (n-bisect.bisect_right(c,b[i]))
print(ans)
# Original solution
N = int(eval(input()))

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

A = sorted(A,reverse=True)
B = sorted(B,reverse=True)
C = sorted(C,reverse=True)

count = 0
for i in range(N):
    a = A[i]
    for j in range(N):
        b = B[j]
        if a >= b:
            #flag = True
            break
        for k in range(N):
            c = C[k]
            if b >= c:
                break
            #print(a,b,c)
            count += 1
print(count)


# Optimized solution
def bs_left(A, target):
    low, high = 0, len(A)
    while low<high:
        mid = (low+high)//2
        if A[mid]<target:
            low = mid+1
        else:
            high = mid
    return low

def bs_right(C, target):
    low, high = 0, len(C)
    while low<high:
        mid = (low+high)//2
        if target<C[mid]:
            high = mid
        else:
            low = mid+1
    return low
if __name__ == '__main__':
    N = int(eval(input()))

    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))
    A = sorted(A)
    B = sorted(B)
    C = sorted(C)

    count = 0
    for i in range(N):
        b = B[i]
        count = count + bs_left(A,b) * (N - bs_right(C,b))
    print(count)
# Original solution
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    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()

    def binsearch_left(a, x):
        l = -1
        r = len(a)
        while r-l>1:
            m = (l+r)//2
            if x<a[m]:
                r = m
            else:
                l = m
        return r

    def binsearch_right(a, x):
        l = -1
        r = len(a)
        while r-l>1:
            m = (l+r)//2
            if x<=a[m]:
                r = m
            else:
                l = m
        return r

    ans = 0
    for b in B:
        a_r = binsearch_right(A, b)
        c_l = binsearch_left(C, b)
        ans += a_r * (N - c_l)

    print(ans)

if __name__ == '__main__':
    resolve()


# Optimized solution
import sys
input = lambda: sys.stdin.readline().rstrip() 
import bisect

def resolve():
    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_r = bisect.bisect_left(A, b)
        c_l = bisect.bisect_right(C, b)
        ans += a_r * (N - c_l)

    print(ans)

if __name__ == '__main__':
    resolve()
# Original solution

import bisect

def solve(N,A,B,C):

    # A=['3', '14', '159', '2', '6', '53']
    # B=['58', '9', '79', '323', '84', '6']
    # C=['2643', '383', '2', '79', '50', '288']
    A,B,C=list(map(int, A)),list(map(int, B)),list(map(int, C))
    A=sorted(A)
    B=sorted(B)
    C=sorted(C)
    # print(A)
    # print(B)
    # print(C)
    D = [0]*N
    E = [0]*N
    for i in range(N):
        a = A[i]
        # print(N-bisect.bisect_right(B,a))
        D[i]= N-bisect.bisect_right(B,a)
        #bはaより大きい数字が何個あるか分かれば良い
        #cはbの
    # print(D)

    for i in range(N):
        b = B[i]
        E[i] = N-bisect.bisect_right(C,b)
    
    # print(E)
    answer = 0
    for i in range(N):
        d=N-D[i]
        answer+=sum(E[d:])

    print(answer)

    
 
 
def main():
    N = int(eval(input()))
    A=input().rstrip().split()
    B=input().rstrip().split()
    C=input().rstrip().split()
    solve(N,A,B,C)

 
 
if __name__ == '__main__':
    main()

# Optimized solution

import bisect

def solve(N,A,B,C):

    # A=['3', '14', '159', '2', '6', '53']
    # B=['58', '9', '79', '323', '84', '6']
    # C=['2643', '383', '2', '79', '50', '288']
    A,B,C=list(map(int, A)),list(map(int, B)),list(map(int, C))
    A=sorted(A)
    B=sorted(B)
    C=sorted(C)
    # print(A)
    # print(B)
    # print(C)
    D = [0]*N
    # E = [0]*N
    # for i in range(N):
    #     a = A[i]
    #     # print(N-bisect.bisect_right(B,a))
    #     D[i]= N-bisect.bisect_right(B,a)
    #     #bはaより大きい数字が何個あるか分かれば良い
    #     #cはbの
    # # print(D)

    for i in range(N):
        b = B[i]
        D[i]=bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b))
        # print(b,'より小さいのは',bisect.bisect_left(A,b))
        # print(b,'より大きいのは',N-bisect.bisect_right(C,b))
    print((sum(D)))
    # print(E)
    # answer = 0
    # for i in range(N):
    #     d=N-D[i]
    #     answer+=sum(E[d:])

    # print(answer)

    
 
 
def main():
    N = int(eval(input()))
    # A,B,C=0,0,0
    A=input().rstrip().split()
    B=input().rstrip().split()
    C=input().rstrip().split()
    solve(N,A,B,C)

 
 
if __name__ == '__main__':
    main()
# Original solution
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()

b_num = [0 for _ in range(len(b))]
for b_i in range(len(b)):
    c_i = bisect.bisect_right(c, b[b_i])
    b_num[b_i] = len(b) - c_i

ans = 0
for a_i in range(len(a)):
    b_i = bisect.bisect_right(b, a[a_i])
    for j in range(b_i, len(b_num)):
        ans += b_num[j]
print(ans)



# Optimized solution
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()

b_num = [0 for _ in range(n)]
for b_i in range(n):
    c_i = bisect.bisect_right(c, b[b_i])
    b_num[b_i] = n - c_i

for i in range(1, len(b_num)):
    b_num[len(b_num) - 1 - i] += b_num[len(b_num) - i]

ans = 0
for a_i in range(len(a)):
    b_i = bisect.bisect_right(b, a[a_i])
    if b_i >= n:
        continue
    ans += b_num[b_i]
print(ans)
# Original solution
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline.rstrip()
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(eval(input()))
def inpm(): return list(map(int,input().split()))
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(eval(input())) for _ in range(n))
def inplL(n): return [list(eval(input())) for _ in range(n)]
def inplT(n): return [tuple(eval(input())) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
d = defaultdict(int)
pre = 0
for b in B:
    tmp = bisect.bisect_right(C[pre:],b)
    pre += tmp
    d[b] = n - pre

pre = 0
for a in A:
    tmp = bisect.bisect_right(B[pre:],a)
    pre += tmp
    for b in B[pre:]:
        ans += d[b]

print(ans)

# Optimized solution
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(eval(input()))
def inpm(): return list(map(int,input().split()))
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(eval(input())) for _ in range(n))
def inplL(n): return [list(eval(input())) for _ in range(n)]
def inplT(n): return [tuple(eval(input())) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
for b in B:
    tmp = bisect.bisect_right(C,b)
    tmp2 = bisect.bisect_left(A,b)
    ans += (n-tmp) * tmp2

print(ans)
# Original solution
from bisect import bisect_left, bisect_right

N = int(eval(input()))
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])

ans = 0
for b in B:
    ans += len(A[:bisect_right(A, b - 1)]) * len(C[bisect_left(C, b + 1):])
print(ans)


# Optimized solution
from bisect import bisect_left, bisect_right

N = int(eval(input()))
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])

ans = 0
for b in B:
    ans += bisect_right(A, b - 1) * (N - bisect_left(C, b + 1))
print(ans)
# Original solution
N = int(eval(input()))
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
Clist = sorted(list(map(int, input().split())))

def binary_search(num_list, target):
    ans_counter = 0
    if target <= num_list[0]:
        return -1
    
    if num_list[-1] < target:
        return(len(num_list))
    
    while True:

        middle = num_list[len(num_list) // 2]
        left = num_list[:len(num_list) // 2]
        right = num_list[len(num_list) // 2:]

        if target > left[-1] and right[0] >= target:
            ans_counter += len(left)
            return ans_counter

        elif target <= left[-1]:
            num_list = left
    
        elif right[0] < target:
            ans_counter += len(left)
            num_list = right
ans = 0
for C in Clist:
    b_point = 0
    b_point =  binary_search(Blist, C)

    if b_point >= 0:
        for B in Blist[:b_point]:
            a_point =  binary_search(Alist, B)
#            print(B,C,a_point) 
            ans += (a_point)

print(ans)
#for C in Clist:
    




# Optimized solution
import bisect

N = int(eval(input()))
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
Clist = sorted(list(map(int, input().split())))

ans = 0

for B in Blist:
    Aindex = bisect.bisect_left(Alist, B)
    Cindex = bisect.bisect_right(Clist, B)

#    print(B, Aindex, N-Cindex)
    ans += Aindex * (N - Cindex)

print(ans)
# Original solution

def read_input():
    n = int(eval(input()))
    alist = list(map(int, input().split()))
    blist = list(map(int, input().split()))
    clist = list(map(int, input().split()))

    return n, alist, blist, clist


def submit():
    n, alist, blist, clist = read_input()

    alist.sort(reverse=True)
    blist.sort(reverse=True)
    clist.sort(reverse=True)


    i = j = 0

    count = 0
    while i < n:
        # 下段を選ぶ
        c = clist[i]

        # 下段で選んだcよりも小さいb候補を探す
        while j < n and blist[j] >= c:
            j += 1
            if j == n:
                break
        bcand = blist[j:]

        for b in bcand:
            # b候補より小さいa候補を探す
            k = 0
            while k < n and alist[k] >= b:
                k += 1
                if k == n:
                    break
            # このkより右側は構成可能
            count += (n - k)
        i += 1

    print(count)
    return



if __name__ == '__main__':
    submit()

# Optimized solution

def read_input():
    n = int(eval(input()))
    alist = list(map(int, input().split()))
    blist = list(map(int, input().split()))
    clist = list(map(int, input().split()))

    return n, alist, blist, clist


def submit():
    n, alist, blist, clist = read_input()

    alist.sort(reverse=True)
    blist.sort(reverse=True)
    clist.sort(reverse=True)

    b_a_n = [0] * n
    i = j = 0

    while j < n:
        while i < n and alist[i] >= blist[j]:
            i += 1
        b_a_n[j] = n - i
        j += 1

    b_a_sum = b_a_n.copy()
    for i in range(2, n + 1):
        b_a_sum[n - i] = b_a_sum[n - i + 1] + b_a_n[n - i]

    count = 0
    i = j = 0
    while i < n:
        while blist[j] >= clist[i]:
            j += 1
            if j == n:
                print(count)
                return
        count += b_a_sum[j]
        i += 1

    print(count)

if __name__ == '__main__':
    submit()
# Original solution
import bisect
import sys
input = sys.stdin.readline


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()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += len(A[:a_index])*len(C[c_index:])
print(cnt)

# Optimized solution
import bisect
import sys
input = sys.stdin.readline


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()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += a_index*(N-c_index)
print(cnt)
# Original solution
n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for ai in a:
    for bi in b:
        if bi <= ai:
            break
        for ci in c:
            if ci <= bi:
                break
            ans += 1
print(ans)

# Optimized solution
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())))
ans = 0
for bi in b:
    upper = bisect.bisect_left(a, bi)
    lower = n - bisect.bisect_right(c, bi)
    ans += upper * lower
print(ans)
# Original solution
def binarySearchLeft(nums, target):
    low = 0
    high = len(nums) - 1
    while low <= high:
        mid = low + high >> 1
        if target == nums[mid]:
            if mid == 0 or target != nums[mid - 1]:
                return mid
            else:
                high = mid - 1
        elif target < nums[mid]:
            high = mid - 1
        else:
            low = mid + 1
    return low

def solve(N, A, B, C):
     A.sort()
     B.sort()
     C.sort()
     ret = 0
     for a in A:
         b_idx = binarySearchLeft(B, a + 1)
         if not (0 <= b_idx < N):
             continue
         for j in range(b_idx, N):
             c_idx = binarySearchLeft(C, B[j] + 1)
             ret += N - c_idx if 0 <= c_idx < N else 0
     print(ret)

if __name__ == "__main__":
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    solve(N, A, B, C)


# Optimized solution
def binarySearchLeft(nums, target):
    low = 0
    high = len(nums) - 1
    while low <= high:
        mid = low + high >> 1
        if target == nums[mid]:
            if mid == 0 or target != nums[mid - 1]:
                return mid
            else:
                high = mid - 1
        elif target < nums[mid]:
            high = mid - 1
        else:
            low = mid + 1
    return low

def binarySearchRight(nums, target):
    low = 0
    high = len(nums) - 1
    while low <= high:
        mid = low + high >> 1
        if target == nums[mid]:
            if mid == len(nums) - 1 or target != nums[mid + 1]:
                return mid
            else:
                low = mid + 1
        elif target < nums[mid]:
            high = mid - 1
        else:
            low = mid + 1
    return high

def solve(N, A, B, C):
     A.sort()
     B.sort()
     C.sort()
     ret = 0
     for j in range(N):
         i = binarySearchRight(A, B[j] - 1)
         k = binarySearchLeft(C, B[j] + 1)
         ret += (i + 1) * (N - k) if 0 <= i < N and 0 <= k < N else 0
     print(ret)

if __name__ == "__main__":
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    solve(N, A, B, C)