#include<bits/stdc++.h>
#define ll long long
#define w cout
#define e endl
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    ll arr[n];
    ll gcd = 0 , mul = 1;
    for(int i = 0; i < n ;i ++ ) {
        cin >> arr[i];
        mul *= arr[i];
        gcd = __gcd(gcd , arr[i]);
    }
    
    ll ans = 0 , maxsum = 0;
    long long lcm = mul / gcd;
    
    ans = lcm - 1;
    
    for(int i = 0 ; i < n ; i ++ ) {
        maxsum += ans % arr[i];
    }
    w << maxsum;
}
