#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  ll ans = 0;
  ll ma = *max_element(a.begin(), a.end());
  for (ll i = 1; i <= ma; i++) {
    ll sum = 0;
    for (ll j = 0; j < n; j++) {
      sum += i % a[j];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
}
