import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Maybe as Maybe
import qualified Text.Printf as Printf
import qualified Control.Monad as Monad

bisectLeft :: (Ord a) => a -> [a] -> Int
bisectLeft n xs = bisectLeft' 0 (length xs) n xs

bisectLeft' :: (Ord a) => Int -> Int -> a -> [a] -> Int
bisectLeft' lo hi n xs = if lo >= hi then lo else
                    if n <= (xs !! mid) then bisectLeft' lo mid n xs
                      else bisectLeft' (mid + 1) hi n xs
                    where mid = (lo + hi) `div` 2

bisectRight :: (Ord a) => a -> [a] -> Int
bisectRight n xs = bisectRight' 0 (length xs) n xs

bisectRight' :: (Ord a) => Int -> Int -> a -> [a] -> Int
bisectRight' lo hi n xs = if lo >= hi then hi else
                    if n < (xs !! mid) then bisectRight' lo mid n xs
                      else bisectRight' (mid + 1) hi n xs
                    where mid = (lo + hi) `div` 2

main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  as <- List.sort . map (read :: String -> Int) . words <$> getLine
  bs <- map (read :: String -> Int) . words <$> getLine
  cs <- List.sort . map (read :: String -> Int) . words <$> getLine
  print $ foldl (+) 0 $ map (\ b -> (bisectLeft b as) * (n - bisectRight b cs)) bs