#include <bits/stdc++.h>
using namespace std;
int f(int x, const vector<int>& a) {
  int c = 0;
  for (auto& i : a) {
    c += x % i;
  }
  return c;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int max_ = 0;
  int me = *max_element(a.begin(), a.end());
  for (int i = 0; i < me; i++) {
    max_ = max(max_, f(me + 1 + i, a));
  }
  cout << max_ << endl;
}
