

import sys

# import collections

# import math

# import string

import bisect



def main():

    n, *parts = (int(x) for x in sys.stdin.read().split())

    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))

    uppers.sort()

    lowers.sort()



    count = 0

    for j in middles:

        i = bisect.bisect_left(uppers, j)

        k = len(lowers) - bisect.bisect_right(lowers, j)

        count += i * k

        

    print(count)



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, = list(map(int, sys.stdin.readline().split()))

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

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



def main():

    a.sort()

    b.sort()

    c.sort()

    res = 0

    for i in b:

        cnt_a = bi_l(a, i)

        cnt_c = n - bi_r(c, i)

        res += cnt_a * cnt_c

 

    return res

    

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys

# import collections
# import math
# import string
import bisect


def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n * i : n * (i + 1)] for i in range(3))
    uppers.sort()
    lowers.sort()
    count = 0
    for j in middles:
        i = bisect.bisect_left(uppers, j)
        k = len(lowers) - bisect.bisect_right(lowers, j)
        count += i * k
    print(count)


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,) = list(map(int, sys.stdin.readline().split()))
(*b,) = list(map(int, sys.stdin.readline().split()))
(*c,) = list(map(int, sys.stdin.readline().split()))


def main():
    a.sort()
    b.sort()
    c.sort()
    res = 0
    for i in b:
        cnt_a = bi_l(a, i)
        cnt_c = n - bi_r(c, i)
        res += cnt_a * cnt_c
    return res


if __name__ == "__main__":
    ans = main()
    print(ans)

+from bisect import bisect_left as bi_l, bisect_right as bi_r -# import collections -# import math -# import string -import bisect +n = int(sys.stdin.readline().rstrip()) +(*a,) = list(map(int, sys.stdin.readline().split())) +(*b,) = list(map(int, sys.stdin.readline().split())) +(*c,) = list(map(int, sys.stdin.readline().split())) -    n, *parts = (int(x) for x in sys.stdin.read().split()) -    uppers, middles, lowers = (parts[n * i : n * (i + 1)] for i in range(3)) -    uppers.sort() -    lowers.sort() -    count = 0 -    for j in middles: -        i = bisect.bisect_left(uppers, j) -        k = len(lowers) - bisect.bisect_right(lowers, j) -        count += i * k -    print(count) +    a.sort() +    b.sort() +    c.sort() +    res = 0 +    for i in b: +        cnt_a = bi_l(a, i) +        cnt_c = n - bi_r(c, i) +        res += cnt_a * cnt_c +    return res -    main() +    ans = main() +    print(ans)