import Control.Monad

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

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

solve :: Int -> Int -> [Int] -> Answer
solve e t = go e []
  where
    go x js (i : is)
      | null is   = z
      | otherwise = go z ((i, x) : js) is
      where
        z = dp js i (x + t)

    dp              []  _ = id
    dp ((j, x) : js) i
      | t > 2 * d = next dp  id (x + t)
      | otherwise = next dp2 (subtract $ 2 * i) (x - 2 * j)
      where
        d = i - j
        next f g = flip $ (f js i .) . flip min . g

    dp2           []  i = (2 * i +)
    dp2 ((j, x) : js) i = dp2 js i . min (x - 2 * j)
