# ABC084C - Snuke Festival

# Binary search

from bisect import bisect_left, bisect_right



n = int(eval(input()))

A, B, C = [sorted(list(map(int, input().rstrip().split()))) for _ in range(3)]

lgth = len(C)

ans = 0

for i in B:

    ans += bisect_left(A, i) * (lgth - bisect_right(C, i))

print(ans)
# ARC084C - Snuke Festival

from bisect import bisect_left, bisect_right



def main():

    n = int(eval(input()))

    A, B, C = [sorted(tuple(map(int, input().rstrip().split()))) for _ in range(3)]

    l, ans = len(C), 0

    for i in B:

        ans += bisect_left(A, i) * (l - bisect_right(C, i))

    print(ans)





if __name__ == "__main__":

    main()
# ABC084C - Snuke Festival
# Binary search
from bisect import bisect_left, bisect_right

n = int(eval(input()))
A, B, C = [sorted(list(map(int, input().rstrip().split()))) for _ in range(3)]
lgth = len(C)
ans = 0
for i in B:
    ans += bisect_left(A, i) * (lgth - bisect_right(C, i))
print(ans)

# ARC084C - Snuke Festival
from bisect import bisect_left, bisect_right


def main():
    n = int(eval(input()))
    A, B, C = [sorted(tuple(map(int, input().rstrip().split()))) for _ in range(3)]
    l, ans = len(C), 0
    for i in B:
        ans += bisect_left(A, i) * (l - bisect_right(C, i))
    print(ans)


if __name__ == "__main__":
    main()

-# ABC084C - Snuke Festival -# Binary search +# ARC084C - Snuke Festival -n = int(eval(input())) -A, B, C = [sorted(list(map(int, input().rstrip().split()))) for _ in range(3)] -lgth = len(C) -ans = 0 -for i in B: -    ans += bisect_left(A, i) * (lgth - bisect_right(C, i)) -print(ans) + +def main(): +    n = int(eval(input())) +    A, B, C = [sorted(tuple(map(int, input().rstrip().split()))) for _ in range(3)] +    l, ans = len(C), 0 +    for i in B: +        ans += bisect_left(A, i) * (l - bisect_right(C, i)) +    print(ans) + + +if __name__ == "__main__": +    main()