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

fn lcm(a: u64, b: u64) -> u64 {
    (a * b) / gcd(a, b)
}

fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a_s = iter.take(n).map(|a| a.parse().unwrap()).collect::<Vec<u64>>();
    let mut lcm_all = a_s[0];
    for &a in a_s[1..].iter() {
        lcm_all = lcm(lcm_all, a);
    }
    let mut ans = 0;
    for a in a_s {
        ans += (lcm_all - 1) % a;
    }
    println!("{}", ans);
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}
