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



res = 0

for i in range(n):

    index1 = bisect.bisect_left(a, b[i])

    index2 = bisect.bisect_right(c, b[i])

    res += index1 * (n - index2)



print(res)

import sys

from bisect import bisect_left, bisect_right



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

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



    res = 0

    for i in range(n):

        u = bisect_left(A, B[i])

        d = bisect_right(C, B[i])

        res += u * (n - d)

    print(res)





if __name__ == '__main__':

    resolve()

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())))
res = 0
for i in range(n):
    index1 = bisect.bisect_left(a, b[i])
    index2 = bisect.bisect_right(c, b[i])
    res += index1 * (n - index2)
print(res)

import sys
from bisect import bisect_left, bisect_right

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


def resolve():
    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())))
    res = 0
    for i in range(n):
        u = bisect_left(A, B[i])
        d = bisect_right(C, B[i])
        res += u * (n - d)
    print(res)


if __name__ == "__main__":
    resolve()

-import bisect +import sys +from bisect import bisect_left, bisect_right -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()))) -res = 0 -for i in range(n): -    index1 = bisect.bisect_left(a, b[i]) -    index2 = bisect.bisect_right(c, b[i]) -    res += index1 * (n - index2) -print(res) +sys.setrecursionlimit(10**7) +input = sys.stdin.readline +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    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()))) +    res = 0 +    for i in range(n): +        u = bisect_left(A, B[i]) +        d = bisect_right(C, B[i]) +        res += u * (n - d) +    print(res) + + +if __name__ == "__main__": +    resolve()