#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < (n); ++i) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end(), greater<int>());
  long long int ans = 0;
  for (long long int i = 0; i <= a[0] * 2; i++) {
    long long int num = 0;
    for (long long int j = 0; j < n; j++) {
      num += i % a[j];
    }
    ans = max(ans, num);
  }
  cout << ans << endl;
  return 0;
}
