#include<bits/stdc++.h>
#include <numeric>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;

int gcd_arr(vi &a){
    int n = a.size();
    for(int i = n-2; i >= 0; i--){
        a[i] = gcd(a[i], a[i+1]);
    }
    return a.front();
}


signed main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi copy = a;
    int gcd_of_a = gcd_arr(copy);
    int ans = 0;
    rep(i, n){
        ans += (gcd_of_a - 1) % a[n];
    }
    cout << ans << endl;
}