from sys import stdin

import math

import bisect

import heapq

import numpy as np

from math import factorial



n = int(stdin.readline().rstrip())

a = list(map(int,stdin.readline().rstrip().split()))

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

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



a.sort()

b.sort()

c.sort()



total = 0

for i in range(n):

    l = bisect.bisect(a,b[i]-1)

    r = n -bisect.bisect_left(c,b[i]+1)

    total += l*r



print(total)
import bisect



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

C = len(c)



# Bを中心に考える

for i in b:

    ans += (bisect.bisect_right(a,i-1))*(C-bisect.bisect_left(c,i+1))



print(ans)
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial

n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))
c = list(map(int, stdin.readline().rstrip().split()))
a.sort()
b.sort()
c.sort()
total = 0
for i in range(n):
    l = bisect.bisect(a, b[i] - 1)
    r = n - bisect.bisect_left(c, b[i] + 1)
    total += l * r
print(total)

import bisect

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
C = len(c)
# Bを中心に考える
for i in b:
    ans += (bisect.bisect_right(a, i - 1)) * (C - bisect.bisect_left(c, i + 1))
print(ans)

-from sys import stdin -import math -import heapq -import numpy as np -from math import factorial -n = int(stdin.readline().rstrip()) -a = list(map(int, stdin.readline().rstrip().split())) -b = list(map(int, stdin.readline().rstrip().split())) -c = list(map(int, stdin.readline().rstrip().split())) +n = int(eval(input())) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = list(map(int, input().split())) -total = 0 -for i in range(n): -    l = bisect.bisect(a, b[i] - 1) -    r = n - bisect.bisect_left(c, b[i] + 1) -    total += l * r -print(total) +ans = 0 +C = len(c) +# Bを中心に考える +for i in b: +    ans += (bisect.bisect_right(a, i - 1)) * (C - bisect.bisect_left(c, i + 1)) +print(ans)