import bisect

n = int(eval(input()))

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

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

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



ans = 0

for i in b:

  x = bisect.bisect_left(a,i)

  y = bisect.bisect_right(c, i)

  #print(x, y)

  ans = ans+x*(n-y)



print(ans)
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

for i in b:

  x = bisect.bisect_left(a, i)

  y = bisect.bisect_right(c, i)

  ans = ans + (x * (n-y))

print(ans)
import bisect

n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
    x = bisect.bisect_left(a, i)
    y = bisect.bisect_right(c, i)
    # print(x, y)
    ans = ans + x * (n - y)
print(ans)

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
for i in b:
    x = bisect.bisect_left(a, i)
    y = bisect.bisect_right(c, i)
    ans = ans + (x * (n - y))
print(ans)

-a = sorted(list(map(int, input().split()))) -b = sorted(list(map(int, input().split()))) -c = sorted(list(map(int, input().split()))) +a = list(map(int, input().split())) +b = list(map(int, input().split())) +c = list(map(int, input().split())) +a.sort() +b.sort() +c.sort() -    # print(x, y) -    ans = ans + x * (n - y) +    ans = ans + (x * (n - y))