

import sys

from heapq import heapify,heappop,heappush

from collections import defaultdict

read=sys.stdin.read

readline=sys.stdin.readline



def main():

    n=int(readline())

    a,b,c=(list(map(int,lst.split())) for lst in read().splitlines())

    a.sort()

    b.sort()

    c=[-x for x in c]

    c.sort()



    def bise(x,lst):

        left=0

        right=len(lst)

        while right-left>0:

            mid=(right+left)//2

            if lst[mid]>=x:

                right=mid

            else:

                left=mid+1

        return left

    print((sum(bise(x,a)*bise(-x,c) for x in b)))



if __name__=='__main__':

    main()

      

      

import sys

from bisect import bisect_right,bisect_left

read=sys.stdin.read

readline=sys.stdin.readline



def main():

    n=int(readline())

    a,b,c=(list(map(int,lst.split())) for lst in read().splitlines())

    a.sort()

    b.sort()

    c=[-x for x in c]

    c.sort()

    print((sum(bisect_left(a,x)*bisect_left(c,-x) for x in b)))



if __name__=='__main__':

    main()

      

      

import sys
from heapq import heapify, heappop, heappush
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    n = int(readline())
    a, b, c = (list(map(int, lst.split())) for lst in read().splitlines())
    a.sort()
    b.sort()
    c = [-x for x in c]
    c.sort()

    def bise(x, lst):
        left = 0
        right = len(lst)
        while right - left > 0:
            mid = (right + left) // 2
            if lst[mid] >= x:
                right = mid
            else:
                left = mid + 1
        return left

    print((sum(bise(x, a) * bise(-x, c) for x in b)))


if __name__ == "__main__":
    main()

import sys
from bisect import bisect_right, bisect_left

read = sys.stdin.read
readline = sys.stdin.readline


def main():
    n = int(readline())
    a, b, c = (list(map(int, lst.split())) for lst in read().splitlines())
    a.sort()
    b.sort()
    c = [-x for x in c]
    c.sort()
    print((sum(bisect_left(a, x) * bisect_left(c, -x) for x in b)))


if __name__ == "__main__":
    main()

-from heapq import heapify, heappop, heappush -from collections import defaultdict +from bisect import bisect_right, bisect_left - -    def bise(x, lst): -        left = 0 -        right = len(lst) -        while right - left > 0: -            mid = (right + left) // 2 -            if lst[mid] >= x: -                right = mid -            else: -                left = mid + 1 -        return left - -    print((sum(bise(x, a) * bise(-x, c) for x in b))) +    print((sum(bisect_left(a, x) * bisect_left(c, -x) for x in b)))