use proconio::input;

fn gcv(a:usize, b:usize)->usize {
  if b == 0 {
    a
  } else {
    gcv(b, a %b)
  }
}

fn lcm(a:usize, b:usize)->usize {
  a * b / gcv(a, b)
}

fn main() {
  input! {
    n: usize,
    vals: [usize; n]
  }
  
  let mut val = 1;
  for v in vals.iter() {
    val = lcm(val, *v);
  }

  let mut result = 0;
  let v = val - 1;
  let mut total = 0;
  for i in 0..n {
    total += v % vals[i];
  }
  result = std::cmp::max(result, total);
  println!("{}", result);
}