import sys

from bisect import bisect_left as bi_l, bisect_right as bi_r



n = int(sys.stdin.readline().rstrip())

a = sorted(map(int, sys.stdin.readline().split()))

b = sorted(map(int, sys.stdin.readline().split()))

c = sorted(map(int, sys.stdin.readline().split()))



def main():

    combs = 0

    for x in b:

        combs += bi_l(a, x) * (n - bi_r(c, x))

    print(combs)



if __name__ ==  '__main__':

    main()
import sys

import numpy as np



n = int(sys.stdin.readline().rstrip())

a, b, c = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, n)

a.sort(); c.sort()



def main():

    print((np.sum(np.searchsorted(a, b) * (n - np.searchsorted(c, b, side='right')))))



if __name__ ==  '__main__':

    main()
import sys
from bisect import bisect_left as bi_l, bisect_right as bi_r

n = int(sys.stdin.readline().rstrip())
a = sorted(map(int, sys.stdin.readline().split()))
b = sorted(map(int, sys.stdin.readline().split()))
c = sorted(map(int, sys.stdin.readline().split()))


def main():
    combs = 0
    for x in b:
        combs += bi_l(a, x) * (n - bi_r(c, x))
    print(combs)


if __name__ == "__main__":
    main()

import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
a, b, c = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, n)
a.sort()
c.sort()


def main():
    print((np.sum(np.searchsorted(a, b) * (n - np.searchsorted(c, b, side="right")))))


if __name__ == "__main__":
    main()

-from bisect import bisect_left as bi_l, bisect_right as bi_r +import numpy as np -a = sorted(map(int, sys.stdin.readline().split())) -b = sorted(map(int, sys.stdin.readline().split())) -c = sorted(map(int, sys.stdin.readline().split())) +a, b, c = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, n) +a.sort() +c.sort() -    combs = 0 -    for x in b: -        combs += bi_l(a, x) * (n - bi_r(c, x)) -    print(combs) +    print((np.sum(np.searchsorted(a, b) * (n - np.searchsorted(c, b, side="right")))))