-- diverta 2019 D problem
import Control.Monad
import qualified Data.Text as T

-- conversion from String to Int
toInt :: String -> Int
toInt x = read x :: Int

-- obtain [Int] from I/O
getInts :: IO [Int]
getInts = do
  x <- getLine
  let y = (map $ toInt) $ words x
  return y

-- calculation of answer
proD :: Integer -> [Integer]-> Integer
proD n [] = 0
proD n (x:xs) =
    if (mod n x == 0) && ((mod n (x-1)) > 0) then (x-1)+(proD n xs)
    else (proD n xs)

-- main function
main :: IO ()
main = do
  n1 <- getInts
  let n = toInteger (head n1)
  print (proD n [2..n])