import           Control.Monad
import           Data.Foldable
import qualified Data.IntMap.Strict as M
import           Data.List
import           Data.Ratio

main :: IO ()
main = do
    [n, c, k] <- map read .words <$> getLine
    ts <- replicateM n readLn
    print $ solve c k ts

solve :: Int -> Int -> [Int] -> Int
solve c k ts = calc c k (count ts) ts

count :: [Int] ->  M.IntMap Int
count = foldr (\k mp -> M.insertWith (+) k 1 mp) M.empty

calc :: Int -> Int -> M.IntMap Int -> [Int] -> Int
calc c k mp [] = 0
calc c k mp (t:ts) = calc c k mp' ts + n
    where
        mp' = fastRide r (t + k) $ snd $ M.split (t + k) mp
        p = sum $ fst $ M.split (t + k + 1) mp
        n = ceiling (p % c) 
        r = n * c - p

fastRide :: Int -> Int -> M.IntMap Int -> M.IntMap Int
fastRide 0 u mp = mp
fastRide n u mp
    | M.null mp = mp
    | k > u     = mp
    | v > n     = M.insert k (v - n) mp'
    | otherwise = fastRide (n - v) u mp'
    where ((k, v), mp') = M.deleteFindMin mp