#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string char_to_string(char val) { return string(1, val); }
int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> a[i];
  ll result = 0;
  ll sum = 0;
  for (ll i = 2; i <= 100000; ++i) {
    for (ll k = 0; k < N; ++k) {
      int tmp = i % a[k];
      sum = sum + tmp;
    }
    if (result < sum) {
      result = sum;
    }
    sum = 0;
  }
  cout << result << endl;
}
