#include <bits/stdc++.h>
using namespace std;
signed main() {
  int ti = clock();
  long long N, ans = 0, tmp;
  cin >> N;
  vector<long long> a(N);
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> a[i];
  }
  long long i = 0;
  while (1.0 * (clock() - ti) / CLOCKS_PER_SEC < 1.97) {
    tmp = 0;
    for (int j = 0; j < N; j++) {
      tmp += i % a[j];
    }
    ans = max(ans, tmp);
    i++;
  }
  cout << ans << endl;
  ;
  return 0;
}
