import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.numeric;

void main() {
    const N = readln.chomp.to!long;
    const as = readln.split.to!(long[]);
    auto g = as.reduce!((a,b) => gcd(a,b));
    auto l = as.map!(a => a / g).reduce!((a,b) => a * b) * g;
    writeln(as.map!(a => (l-1) % a).sum);
}

