function gcd(a, b, t){
    if(a<b){t=a;a=b;b=t}
    if(!b)return a
    return gcd(b, a%b)
}
function lcm(a, b){return a * b / gcd(a, b)}
NR==2{split($0,a)}
END{
	t=1
    for(i in a)t=lcm(t,a[i])
    for(i in a)ans+=(t-1)%a[i]
    print ans
}