from collections import deque

from collections import Counter

from itertools import product, permutations,combinations

from operator import itemgetter

from heapq import heappop, heappush

from bisect import bisect_left, bisect_right, bisect

#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree

#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix

from fractions import gcd

from math import ceil,floor, sqrt, cos, sin, pi

#import numpy as np

import sys

input = sys.stdin.readline

#文字列のときはうまく行かないのでコメントアウトすること

sys.setrecursionlimit(2147483647)



def main():

  n = int(eval(input()))

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

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

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

  A.sort()

  B.sort()

  C.sort()

  ans = 0

  for y in B:

    i = bisect_left(A, y)

    j = bisect_right(C,y)

    if i>0 and j != len(C):

      ans += i*(n-j)

  print(ans)



if __name__ == '__main__':

  main()
import sys

from bisect import bisect_right, bisect_left
from functools import reduce

readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)

INF = float('inf')

MOD = 10 ** 9 + 7



def lcm_base(x, y):

    return (x * y) // gcd(x, y)



def lcm_list(numbers):

    return reduce(lcm_base, numbers, 1)



def main():

    N = int(readline())

    A = list(map(int, readline().split()))

    B = list(map(int, readline().split()))

    C = list(map(int, readline().split()))

    A.sort()

    B.sort()

    C.sort()

    ans = 0

    for i in range(N):

        top = bisect_left(A, B[i])

        bottom = bisect_right(C, B[i])

        if top>0 and bottom != N:

            ans += top*(N-bottom)

    print(ans)

if __name__ == '__main__':

    main()
from collections import deque
from collections import Counter
from itertools import product, permutations, combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect

# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi

# import numpy as np
import sys

input = sys.stdin.readline
# 文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)


def main():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()
    ans = 0
    for y in B:
        i = bisect_left(A, y)
        j = bisect_right(C, y)
        if i > 0 and j != len(C):
            ans += i * (n - j)
    print(ans)


if __name__ == "__main__":
    main()

import sys
from bisect import bisect_right, bisect_left
from functools import reduce

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))
    A.sort()
    B.sort()
    C.sort()
    ans = 0
    for i in range(N):
        top = bisect_left(A, B[i])
        bottom = bisect_right(C, B[i])
        if top > 0 and bottom != N:
            ans += top * (N - bottom)
    print(ans)


if __name__ == "__main__":
    main()

-from collections import deque -from collections import Counter -from itertools import product, permutations, combinations -from operator import itemgetter -from heapq import heappop, heappush -from bisect import bisect_left, bisect_right, bisect +import sys +from bisect import bisect_right, bisect_left +from functools import reduce -# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree -# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix -from fractions import gcd -from math import ceil, floor, sqrt, cos, sin, pi +readline = sys.stdin.buffer.readline +sys.setrecursionlimit(10**8) +INF = float("inf") +MOD = 10**9 + 7 -# import numpy as np -import sys -input = sys.stdin.readline -# 文字列のときはうまく行かないのでコメントアウトすること -sys.setrecursionlimit(2147483647) +def lcm_base(x, y): +    return (x * y) // gcd(x, y) + + +def lcm_list(numbers): +    return reduce(lcm_base, numbers, 1) -    n = int(eval(input())) -    A = list(map(int, input().split())) -    B = list(map(int, input().split())) -    C = list(map(int, input().split())) +    N = int(readline()) +    A = list(map(int, readline().split())) +    B = list(map(int, readline().split())) +    C = list(map(int, readline().split())) -    for y in B: -        i = bisect_left(A, y) -        j = bisect_right(C, y) -        if i > 0 and j != len(C): -            ans += i * (n - j) +    for i in range(N): +        top = bisect_left(A, B[i]) +        bottom = bisect_right(C, B[i]) +        if top > 0 and bottom != N: +            ans += top * (N - bottom)