#include<bits/stdc++.h>
using namespace std;
#define int long long int

signed main(){
    int t = 1; //cin >> t;
    while(t--){
    	int n; cin >> n;
    	vector<int> a(n);
    	int gcd = 0, prod = 1;
    	for (int i = 0; i < n; ++i)
    	{
    		cin >> a[i];
    		gcd = __gcd(a[i],gcd);
    		prod = prod*a[i];
    	}
    	int lcm = prod/gcd;
    	int ans = n;
    	lcm--;
    	int f = 0;
    	for(auto x:a)
    		f += lcm % x;
    	ans = max(ans,f);
    	cout << ans;
    }    
}