{-# LANGUAGE MultiWayIf #-}

import Data.Bifunctor (first)

main :: IO ()
main = do
    [n, e, t] <- fmap read . words <$> getLine
    xs        <- fmap read . words <$> getLine
    answer $ solve e t xs

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: Int -> Int -> [Int] -> Answer
solve e t = go
  where
    go = fst <$> inner e maxBound id `flip` []

    inner x y dp      []  = (,) x . dp
    inner x y dp (i : is) = do
        js <- dp
        let
          (j, r) = head js
          p      = i - t `div` 2
          x'     = x + t
          w      = min y (x - 2 * i)
          (z, f) = min x' `first` if
            | null js   -> (x', id)
            | j > p     -> (r + t, id)
            | otherwise -> (y + 2 * i, dropWhile ((<= p) . fst))
          dp' = f . dp . ((i, x) :)
        inner z w dp' is
