#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;

vector<Int> A;
Int f(Int m){
    Int ret = 0;
    for(auto it = begin(A); it != end(A); it++){
        ret += m % (*it);
    }
    return ret;
}

int main(){
    Int N;
    cin >> N;

    A = vector<Int>(N);
    Int max_a = 0;
    Int _lcm = 1;
    
    FOR(i, 0, N){
        cin >> A[i];
        _lcm = (_lcm * A[i]) / __gcd(_lcm, A[i]);
    }

    Int ans = 0;

    FOR(m, 1, _lcm){
        Int _f = f(m);
        ans = max(_f, ans);
    }

    COUT(ans);

}
