#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> val(n);
  for (int i = 0; i < n; i++) cin >> val[i];
  int ans = 0, kk;
  for (int i = 1; i <= 200001; i++) {
    kk = 0;
    for (int j = 0; j < n; j++) {
      kk += i % val[i];
    }
    ans = max(ans, kk);
  }
  cout << ans << endl;
}
