#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
long long n, a[200005];
map<long long, long long> f;
signed main() {
  n = read();
  for (register long long i = (1); i <= (n); ++i) a[i] = read();
  f[a[1] - 1] = 0;
  for (register long long i = (1); i <= (n - 1); ++i) {
    long long t = a[i + 1];
    for (auto it = f.lower_bound(a[i + 1]); it != f.end(); ++it) {
      long long x = it->first, val = it->second;
      f[x % t] = max(f[x % t], val + i * (x - x % t));
      f[t - 1] = max(f[t - 1], val + i * ((x + 1) / t * t - t));
    }
    f.erase(f.lower_bound(a[i + 1]), f.end());
  }
  long long res = 0;
  for (auto x : f) res = max(res, x.second + x.first * n);
  cout << res;
  return 0;
}
