# https://atcoder.jp/contests/abc077/tasks/arc084_a

import sys

from bisect import bisect_left, bisect_right





def S(): return sys.stdin.readline().rstrip()





def I(): return int(sys.stdin.readline().rstrip())





def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))





def LS(): return list(sys.stdin.readline().rstrip().split())





N = I()

A = LI()

B = LI()

C = LI()

A.sort()

B.sort()

C.sort()

ans = 0

for b in B:

    ok_a = bisect_left(A, b)

    ok_c = bisect_right(C,b)

    ans += ok_a * (N-ok_c)

print(ans)

import sys

import bisect



def I(): return int(sys.stdin.readline().rstrip())

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def S(): return sys.stdin.readline().rstrip()

def LS(): return list(sys.stdin.readline().rstrip().split())



N = I()

A = LI()

B = LI()

C = LI()



A.sort()

B.sort()

C.sort()

ans = 0



for b in B:

    ok_a = bisect.bisect_left(A,b)

    ok_c = bisect.bisect_right(C,b)

    ans += ok_a*(N-ok_c)

print(ans)
# https://atcoder.jp/contests/abc077/tasks/arc084_a
import sys
from bisect import bisect_left, bisect_right


def S():
    return sys.stdin.readline().rstrip()


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def LS():
    return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()
B = LI()
C = LI()
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    ok_a = bisect_left(A, b)
    ok_c = bisect_right(C, b)
    ans += ok_a * (N - ok_c)
print(ans)

import sys
import bisect


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


def S():
    return sys.stdin.readline().rstrip()


def LS():
    return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()
B = LI()
C = LI()
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    ok_a = bisect.bisect_left(A, b)
    ok_c = bisect.bisect_right(C, b)
    ans += ok_a * (N - ok_c)
print(ans)

-# https://atcoder.jp/contests/abc077/tasks/arc084_a -from bisect import bisect_left, bisect_right - - -def S(): -    return sys.stdin.readline().rstrip() +import bisect + + +def S(): +    return sys.stdin.readline().rstrip() -    ok_a = bisect_left(A, b) -    ok_c = bisect_right(C, b) +    ok_a = bisect.bisect_left(A, b) +    ok_c = bisect.bisect_right(C, b)