f m d v =
  if m `mod` (v+d) == 0
  then d
  else f m (d+1) v

ans l =
  let m = maximum l
      d = map (f m 0) l 
  in
    sum d

main = do
  _ <- getLine
  c <- getContents
  let i = map read $ lines c :: [Int]
      o = ans i
  print o
  