-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = print . solve . map read . words =<< getContents

solve (k:1:_)  = k - 1
solve (k:_:xs) = ans where
    x = maximum xs
    ans = x - (div k 2)
