main = do
  getLine -- discard
  a_tops <- map (\x -> read x :: Int) . words <$> getLine 
  b_mids <- map (\x -> read x :: Int) . words <$> getLine 
  c_btms <- map (\x -> read x :: Int) . words <$> getLine 
  print $ sum $ map (\b -> (length $ filter (<b) a_tops)*(length $ filter (>b) c_btms)) b_mids
