import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod

main = do
 inputs <- readLnInt
 print $ solve inputs

solve [n,a] = (sum apples) - eaten where
 apples = [a+x-1|x<-[1..n]]
 eaten = calc 10000 apples

calc t (a:x) = (null x)?(t',calc t' x) where
 t' = (abs t<abs a)?(t,a)
