{-# LANGUAGE BangPatterns #-}

import Data.Bool  (bool)
import Data.Maybe (fromMaybe, listToMaybe)

import Data.Bifunctor (bimap, 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 = inner (e, maxBound) []

    inner !dp js      []  = fst dp
    inner !dp js (i : is) = inner (x, y) js' is
      where
        p    = i - succ t `div` 2
        !js' = dropWhile ((p >=) . fst) js ++ [(i, dp)]
        !l   = snd <$> listToMaybe (init js')
        !x   = min `uncurry` bimap (+ t) (restrict . (+ 2 * i)) (fromMaybe dp l)
        !y   = min `uncurry` first (subtract $ 2 * i) dp

restrict :: Int -> Int
restrict = until (0 <=) (const maxBound)
