#include <bits/stdc++.h>
using namespace std; 
#define endl '\n' 
typedef long long int lli ; 
using namespace std; 

int main(int argc, char const *argv[])
{	

	unsigned long long n ; 
	cin >> n; 
	vector<unsigned long long> a(n);
	for(unsigned long long i = 0; i<n; ++i){
		cin >> a[i]; 
	} 
	long long lcm  = a[0]; 
	unsigned long long g = a[0]; 
	for(unsigned long long i = 1; i<n; ++i){
		g = __gcd(a[i] , g);
		lcm *= a[i];  

	}
	lcm /= g; 
	lcm--; 
	unsigned long long ans = 0; 
	for(unsigned long long i = 0; i<n; ++i){
		ans += (lcm % a[i] < 0) ? (lcm + a[i]) % a[i] : lcm % a[i];  
	}
	cout << ans ; 
	
	return 0;
}