import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Data.List

type S = VU.Vector Int

-- 下限境界 (Vector 付き)
lowerBoundV :: VU.Vector Int -> (Int, Int) -> Int -> Int
lowerBoundV vec (from, to) target
    | from == to = from
    | mValue >= target = lowerBoundV vec (from, mid) target
    | mValue < target = lowerBoundV vec (mid + 1, to) target
        where
            mid = (from + to) `div` 2
            mValue = vec VU.! mid

-- 上限境界 (Vector 付き)
upperBoundV :: VU.Vector Int -> (Int, Int) -> Int -> Int
upperBoundV vec (from, to) target
    | from == to = from
    | mValue > target = upperBoundV vec (from, mid) target
    | mValue <= target = upperBoundV vec (mid + 1, to) target
        where
            mid = (from + to) `div` 2
            mValue = vec VU.! mid

solve :: S -> S -> S -> Int -> Int
solve xs ys zs n
  | VU.null ys = 0
  | otherwise = res + solve xs ys' zs n
    where
      res = lb * (n - ub)
      y = VU.head ys
      ys' = VU.tail ys
      lb = lowerBoundV xs (0,n) y
      ub = upperBoundV zs (0,n) y

main = do
  n <- readLn :: IO Int
  xs <- VU.fromList . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  ys <- VU.fromList . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  zs <- VU.fromList . sort . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
  print $ solve xs ys zs n