let rec gcd n m =
  if m = 0 then n
  else gcd m (n mod m)

let lcm n m = n / gcd n m * m

let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ ->
    Scanf.scanf "%d " @@ fun a -> a in
  let lcm = Array.fold_left lcm 1 as_ in
  Printf.printf "%d\n" @@ Array.fold_left ( + ) 0 @@ Array.map (fun a -> (lcm - 1) mod a) as_

