#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int m = 1000 * a[n - 1];
  for (int i = 1; i <= m; ++i) {
    int sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += i % a[j];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}
