#include <bits/stdc++.h>
using namespace std;
map<long long, long long> f;
long long a[200010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  f[a[1] - 1] = 0;
  for (int i = 2; i <= n; i++)
    for (auto p = f.lower_bound(a[i]); p != f.end(); f.erase(p++)) {
      long long v = p->first;
      f[v % a[i]] = max(f[v % a[i]], p->second + (i - 1) * (v - v % a[i]));
      f[a[i] - 1] =
          max(f[a[i] - 1], p->second + (i - 1) * ((v + 1) / a[i] - 1) * a[i]);
    }
  long long ans = 0;
  for (auto p : f) ans = max(ans, p.first * n + p.second);
  printf("%lld\n", ans);
  return 0;
}
