from collections import defaultdict, Counter

from itertools import product, groupby, count, permutations, combinations

from math import pi, sqrt

from collections import deque

from bisect import bisect, bisect_left, bisect_right

INF = float("inf")

 

 

def find_lt(a, x):

    i = bisect_left(a, x)

    if i:

        return i

    return 0

 

 

def find_gt(a, x):

    i = bisect_right(a, x)

    if i != len(a):

        return i

    return len(a)

 

 

def main():

    N = int(eval(input()))

    A = list(sorted(list(map(int, input().split()))))

    B = list(sorted(list(map(int, input().split()))))

    C = list(sorted(list(map(int, input().split()))))

 

    ans = 0

    for b in B:

        a = find_lt(A, b)

        b = N - find_gt(C, b)

        ans += a * b

    print(ans)

 

 

if __name__ == '__main__':

    main()
from collections import defaultdict, Counter

from itertools import product, groupby, count, permutations, combinations

from math import pi, sqrt

from collections import deque

from bisect import bisect, bisect_left, bisect_right

from string import ascii_lowercase

from functools import lru_cache

import sys

sys.setrecursionlimit(10000)

INF = float("inf")

YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"

dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]





def inside(y, x, H, W):

    return 0 <= y < H and 0 <= x < W





def ceil(a, b):

    return (a + b - 1) // b





def main():

    N = int(eval(input()))

    A = list(sorted(list(map(int, input().split()))))

    B = list(sorted(list(map(int, input().split()))))

    C = list(sorted(list(map(int, input().split()))))



    ans = 0

    for b in B:

        a = bisect_left(A, b)

        c = N - bisect_right(C, b)

        ans += a * c



    print(ans)





if __name__ == '__main__':

    main()

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right

INF = float("inf")


def find_lt(a, x):
    i = bisect_left(a, x)
    if i:
        return i
    return 0


def find_gt(a, x):
    i = bisect_right(a, x)
    if i != len(a):
        return i
    return len(a)


def main():
    N = int(eval(input()))
    A = list(sorted(list(map(int, input().split()))))
    B = list(sorted(list(map(int, input().split()))))
    C = list(sorted(list(map(int, input().split()))))
    ans = 0
    for b in B:
        a = find_lt(A, b)
        b = N - find_gt(C, b)
        ans += a * b
    print(ans)


if __name__ == "__main__":
    main()

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys

sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(eval(input()))
    A = list(sorted(list(map(int, input().split()))))
    B = list(sorted(list(map(int, input().split()))))
    C = list(sorted(list(map(int, input().split()))))
    ans = 0
    for b in B:
        a = bisect_left(A, b)
        c = N - bisect_right(C, b)
        ans += a * c
    print(ans)


if __name__ == "__main__":
    main()

+from string import ascii_lowercase +from functools import lru_cache +import sys +sys.setrecursionlimit(10000) +YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" +dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] -def find_lt(a, x): -    i = bisect_left(a, x) -    if i: -        return i -    return 0 +def inside(y, x, H, W): +    return 0 <= y < H and 0 <= x < W -def find_gt(a, x): -    i = bisect_right(a, x) -    if i != len(a): -        return i -    return len(a) +def ceil(a, b): +    return (a + b - 1) // b -        a = find_lt(A, b) -        b = N - find_gt(C, b) -        ans += a * b +        a = bisect_left(A, b) +        c = N - bisect_right(C, b) +        ans += a * c