macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn gcd(x: i64, y: i64) -> i64 {
    if y > 0 {
        if x > y {
            return gcd(y, x % y);
        } else {
            return gcd(x, y % x);
        }
    } else {
        return x;
    }
}

fn main() {
    let n: i64 = input!(i64);
    let mut a_vec:Vec<i64> = input!(i64; n);
    let a_vec_clone = a_vec.clone();
    a_vec.sort_by(|a, b| b.cmp(a));
    let mut lcm_value = a_vec.pop().unwrap();
    for value in a_vec.iter() {
        let gcd_value = gcd(*value, lcm_value);
        lcm_value = *value * lcm_value / gcd_value;
    }

    print!("{}", a_vec_clone.iter().map(|x| (lcm_value - 1) % x).fold(0, |sum, i| sum + i));
}