#include <bits/stdc++.h>
using namespace std;
long func(vector<long>* a, long m) {
  long sum = 0;
  long ii;
  for (auto val : *a) {
    sum += m % val;
  }
  return sum;
}
int main() {
  long ii, jj, n;
  vector<long> a;
  long max = 0;
  long sum;
  cin >> n;
  a.resize(n);
  for (ii = 0; ii < n; ii++) {
    cin >> a[ii];
  }
  for (ii = 0; ii < pow(10, 5); ii++) {
    sum = func(&a, ii);
    if (sum > max) {
      max = sum;
    }
  }
  cout << max << endl;
  return 0;
}
