import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

void main()
{
    readln;
    long[] A = readln.chomp.split.to!(long[]);
    auto lcm = (long a, long b) => a * b / gcd(a, b);
    auto f = (long[] A, long x) => A.map!(a => x % a).sum();
    f(A, reduce!lcm(A) - 1).writeln;
}
