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

def bs_left(l, target):

    low, high = 0, len(l)

    while low < high:

        mid = (low+high)//2

        if l[mid] < target:

            low = mid+1

        else:

            high = mid

    return low



def bs_right(l, target):

    low, high = 0, len(l)

    while low < high:

        mid = (low+high)//2

        if target < l[mid]:

            high = mid

        else:

            low = mid+1

    return low

for j in range(N):

    i = bs_left(A,B[j]) 

    k = bs_right(C,B[j])

    if i != 0 and k != -1:

        ans += i*(N-k)

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

import sys, copy, math, heapq, bisect

from itertools import accumulate

from collections import deque, defaultdict, Counter

input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!

sys.setrecursionlimit(500000)

ans = 0

for i in range(N):

    a = bisect.bisect_left(A,B[i])

    c = bisect.bisect_right(C,B[i])



    ans += (N-c)*a

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


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


def bs_right(l, target):
    low, high = 0, len(l)
    while low < high:
        mid = (low + high) // 2
        if target < l[mid]:
            high = mid
        else:
            low = mid + 1
    return low


for j in range(N):
    i = bs_left(A, B[j])
    k = bs_right(C, B[j])
    if i != 0 and k != -1:
        ans += i * (N - k)
print(ans)

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())))
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter

input = sys.stdin.readline  # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)
ans = 0
for i in range(N):
    a = bisect.bisect_left(A, B[i])
    c = bisect.bisect_right(C, B[i])
    ans += (N - c) * a
print(ans)

-A = list(map(int, input().split())) -B = list(map(int, input().split())) -C = list(map(int, input().split())) -A.sort() -B.sort() -C.sort() +A = sorted(list(map(int, input().split()))) +B = sorted(list(map(int, input().split()))) +C = sorted(list(map(int, input().split()))) +import sys, copy, math, heapq, bisect +from itertools import accumulate +from collections import deque, defaultdict, Counter + +input = sys.stdin.readline  # 文字列の入力のとき'/n'まで受け取るので注意!!! +sys.setrecursionlimit(500000) - - -def bs_left(l, target): -    low, high = 0, len(l) -    while low < high: -        mid = (low + high) // 2 -        if l[mid] < target: -            low = mid + 1 -        else: -            high = mid -    return low - - -def bs_right(l, target): -    low, high = 0, len(l) -    while low < high: -        mid = (low + high) // 2 -        if target < l[mid]: -            high = mid -        else: -            low = mid + 1 -    return low - - -for j in range(N): -    i = bs_left(A, B[j]) -    k = bs_right(C, B[j]) -    if i != 0 and k != -1: -        ans += i * (N - k) +for i in range(N): +    a = bisect.bisect_left(A, B[i]) +    c = bisect.bisect_right(C, B[i]) +    ans += (N - c) * a