# coding: utf-8

n = int(eval(input()))

al = sorted(list(int(i) for i in input().split()))

bl = sorted(list(int(i) for i in input().split()))

cl = sorted(list(int(i) for i in input().split()))

ans = 0



def low_left(a, key):

    left = -1

    right = len(a)

    while right - left > 1:

        center = (left + right) // 2

        if a[center] >= key:

            right = center

        else:

            left = center

    return left+1 

    

def high_right(a, key):

    left = -1

    right = len(a)

    while right - left > 1:

        center = (left + right) // 2

        if a[center] <= key:

            left = center

        else:

            right = center

    return n-right

    

for i in bl:

    ans += low_left(al, i) * high_right(cl, i)



print(ans)
import bisect



n = int(eval(input()))

al, bl, cl = list(sorted(map(int, input().split())) for i in range(3))

ans = 0



for key in bl:

    top = bisect.bisect_left(al, key)

    btm = len(cl) - bisect.bisect_right(cl, key)

    ans += top * btm



print(ans)
# coding: utf-8
n = int(eval(input()))
al = sorted(list(int(i) for i in input().split()))
bl = sorted(list(int(i) for i in input().split()))
cl = sorted(list(int(i) for i in input().split()))
ans = 0


def low_left(a, key):
    left = -1
    right = len(a)
    while right - left > 1:
        center = (left + right) // 2
        if a[center] >= key:
            right = center
        else:
            left = center
    return left + 1


def high_right(a, key):
    left = -1
    right = len(a)
    while right - left > 1:
        center = (left + right) // 2
        if a[center] <= key:
            left = center
        else:
            right = center
    return n - right


for i in bl:
    ans += low_left(al, i) * high_right(cl, i)
print(ans)

import bisect

n = int(eval(input()))
al, bl, cl = list(sorted(map(int, input().split())) for i in range(3))
ans = 0
for key in bl:
    top = bisect.bisect_left(al, key)
    btm = len(cl) - bisect.bisect_right(cl, key)
    ans += top * btm
print(ans)

-# coding: utf-8 +import bisect + -al = sorted(list(int(i) for i in input().split())) -bl = sorted(list(int(i) for i in input().split())) -cl = sorted(list(int(i) for i in input().split())) +al, bl, cl = list(sorted(map(int, input().split())) for i in range(3)) - - -def low_left(a, key): -    left = -1 -    right = len(a) -    while right - left > 1: -        center = (left + right) // 2 -        if a[center] >= key: -            right = center -        else: -            left = center -    return left + 1 - - -def high_right(a, key): -    left = -1 -    right = len(a) -    while right - left > 1: -        center = (left + right) // 2 -        if a[center] <= key: -            left = center -        else: -            right = center -    return n - right - - -for i in bl: -    ans += low_left(al, i) * high_right(cl, i) +for key in bl: +    top = bisect.bisect_left(al, key) +    btm = len(cl) - bisect.bisect_right(cl, key) +    ans += top * btm