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

int main() {
    ll n; cin >> n;
    vector<ll> a(n); rep (i, n) cin >> a[i];

    ll ans = 0;
    ll max = max_element(a.begin(), a.end());
    for (ll i = 1; i <= max; i++) {
        ll sum = 0;
        for (ll j = 0; j < n; j++) {
            sum += i % a[j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}
