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