local n = io.read("*n", "*l")
local a, b, c = {}, {}, {}
local str = io.read()
local i = 1
for val in string.gmatch(str, "%d+") do
  a[i] = tonumber(val)
  i = i + 1
end
str = io.read()
i = 1
for val in string.gmatch(str, "%d+") do
  b[i] = tonumber(val)
  i = i + 1
end
str = io.read()
i = 1
for val in string.gmatch(str, "%d+") do
  c[i] = tonumber(val)
  i = i + 1
end
table.sort(a)
table.sort(b)
table.sort(c)
local ab, bc = {}, {}
local bpos, cpos = 1, 1
local alast, blast = n, n
for j = 1, n do
  local tgt = a[j]
  local found = false
  for k = bpos, n do
    if(tgt < b[k]) then
      ab[j], bpos, found = k, k, true
      break
    end
  end
  if(not found) then
    alast = j - 1
    break
  end
end
for j = 1, n do
  local tgt = b[j]
  local found = false
  for k = cpos, n do
    if(tgt < c[k]) then
      bc[j], cpos, found = k, k, true
      break
    end
  end
  if(not found) then
    blast = j - 1
    break
  end
end
for i = blast + 1, n do
  bc[i] = 0
end
if(1 <= blast) then
  bc[blast] = n - bc[blast] + 1
  local prv = bc[blast]
  for i = blast - 1, 1, -1 do
    bc[i] = (n - bc[i] + 1) + prv
    prv = bc[i]
  end
end
local sum = 0
for i = 1, alast do
  sum = sum + bc[ab[i]]
end
print(sum)
