#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
long long a[N];
map<long long, long long> f;
template <typename T>
void umax(T& x, const T& y) {
  if (x < y) x = y;
}
int main() {
  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) {
    while (((int)(f).size())) {
      auto t = *--f.end();
      if (t.first < a[i]) break;
      f.erase(--f.end());
      umax(f[t.first % a[i]],
           t.second + 1LL * (i - 1) * (t.first - t.first % a[i]));
      umax(f[a[i] - 1],
           t.second + 1LL * (i - 1) * ((t.first + 1) / a[i] * a[i] - a[i]));
    }
  }
  long long ans = 0;
  for (auto x : f) umax(ans, 1LL * x.first * n + x.second);
  printf("%lld\n", ans);
  return 0;
}
